src/EditProductTab6.cpp

Thu, 18 Aug 2022 20:34:15 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 18 Aug 2022 20:34:15 +0200
changeset 401
583148eb6e01
parent 395
7212b980a527
child 454
2dfead81c72f
permissions
-rw-r--r--

Init est_carb field for new products.

175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * EditProduct.cpp is part of bmsapp.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * tab 6, yeasts.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * bmsapp is free software: you can redistribute it and/or modify
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * the Free Software Foundation, either version 3 of the License, or
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * (at your option) any later version.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 *
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * bmsapp is distributed in the yeaste that it will be useful,
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * GNU General Public License for more details.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 *
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 bool EditProduct::yeast_sort_test(const Yeasts &D1, const Yeasts &D2)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 {
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
23 if (D1.use > D2.use)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 return false;
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
25 if (D1.use < D2.use)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 return true;
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
27 return (D1.amount > D2.amount);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30
305
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
31 bool EditProduct::block_yeast(int stage, int use)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
32 {
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
33 if (stage > PROD_STAGE_PRIMARY && use < YEAST_USE_SECONDARY)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
34 return true;
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
35 if (stage > PROD_STAGE_SECONDARY && use < YEAST_USE_TERTIARY)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
36 return true;
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
37 if (stage > PROD_STAGE_TERTIARY && use < YEAST_USE_BOTTLE)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
38 return true;
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
39 if (stage > PROD_STAGE_PACKAGE)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
40 return true;
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
41 return false;
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
42 }
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
43
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
44
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 void EditProduct::refreshYeasts()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 QString w;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 QWidget* pWidget;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 QHBoxLayout* pLayout;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 qDebug() << "refreshYeasts" << product->yeasts.size();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 std::sort(product->yeasts.begin(), product->yeasts.end(), yeast_sort_test);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54
179
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
55 const QStringList labels({tr("Yeast"), tr("Laboratory"), tr("Code"), tr("Type"), tr("Use for"), tr("Min."), tr("Max."),
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
56 tr("Tol."), tr("Attn."), tr("Amount"), tr("Stock"), tr("Delete"), tr("Edit") });
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57
179
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
58 ui->yeastsTable->setColumnCount(13);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 ui->yeastsTable->setColumnWidth(0, 200); /* Yeast */
179
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
60 ui->yeastsTable->setColumnWidth(1, 115); /* Laboratory */
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 ui->yeastsTable->setColumnWidth(2, 80); /* Code */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 ui->yeastsTable->setColumnWidth(3, 80); /* Type */
179
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
63 ui->yeastsTable->setColumnWidth(4, 80); /* Usage */
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
64 ui->yeastsTable->setColumnWidth(5, 50); /* Min. */
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
65 ui->yeastsTable->setColumnWidth(6, 50); /* Max. */
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
66 ui->yeastsTable->setColumnWidth(7, 50); /* Tolerance */
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
67 ui->yeastsTable->setColumnWidth(8, 50); /* Attenuation */
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
68 ui->yeastsTable->setColumnWidth(9, 80); /* Amount */
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
69 ui->yeastsTable->setColumnWidth(10, 80); /* Stock */
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
70 ui->yeastsTable->setColumnWidth(11, 80); /* Delete */
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
71 ui->yeastsTable->setColumnWidth(12, 80); /* Edit */
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 ui->yeastsTable->setHorizontalHeaderLabels(labels);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 ui->yeastsTable->verticalHeader()->hide();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 ui->yeastsTable->setRowCount(product->yeasts.size());
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 for (int i = 0; i < product->yeasts.size(); i++) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
78 ui->yeastsTable->setItem(i, 0, new QTableWidgetItem(product->yeasts.at(i).name));
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
79 ui->yeastsTable->setItem(i, 1, new QTableWidgetItem(product->yeasts.at(i).laboratory));
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
80 ui->yeastsTable->setItem(i, 2, new QTableWidgetItem(product->yeasts.at(i).product_id));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 299
diff changeset
82 item = new QTableWidgetItem(QCoreApplication::translate("YeastForm", g_yeast_forms[product->yeasts.at(i).form]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 ui->yeastsTable->setItem(i, 3, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 299
diff changeset
86 item = new QTableWidgetItem(QCoreApplication::translate("YeastUse", g_yeast_use[product->yeasts.at(i).use]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 ui->yeastsTable->setItem(i, 4, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
90 item = new QTableWidgetItem(QString("%1°C").arg(product->yeasts.at(i).min_temperature, 2, 'f', 1, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 ui->yeastsTable->setItem(i, 5, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
94 item = new QTableWidgetItem(QString("%1°C").arg(product->yeasts.at(i).max_temperature, 2, 'f', 1, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 ui->yeastsTable->setItem(i, 6, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
98 item = new QTableWidgetItem(QString("%1%").arg(product->yeasts.at(i).tolerance, 2, 'f', 1, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 ui->yeastsTable->setItem(i, 7, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
102 item = new QTableWidgetItem(QString("%1%").arg(product->yeasts.at(i).attenuation, 2, 'f', 1, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 ui->yeastsTable->setItem(i, 8, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
106 if (product->yeasts.at(i).form == YEAST_FORMS_LIQUID)
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
107 item = new QTableWidgetItem(QString("%1 pack").arg(product->yeasts.at(i).amount, 1, 'f', 0, '0'));
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
108 else if (product->yeasts.at(i).form == YEAST_FORMS_DRY || product->yeasts.at(i).form == YEAST_FORMS_DRIED)
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
109 item = new QTableWidgetItem(QString("%1 gr").arg(product->yeasts.at(i).amount * 1000.0, 3, 'f', 2, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 else
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
111 item = new QTableWidgetItem(QString("%1 ml").arg(product->yeasts.at(i).amount * 1000.0, 3, 'f', 2, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 ui->yeastsTable->setItem(i, 9, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114
305
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
115 if (block_yeast(product->stage, product->yeasts.at(i).use)) {
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
116 item = new QTableWidgetItem(QString(""));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
117 } else {
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
118 if (product->yeasts.at(i).form == YEAST_FORMS_LIQUID)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
119 item = new QTableWidgetItem(QString("%1 pack").arg(product->yeasts.at(i).inventory, 1, 'f', 0, '0'));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
120 else if (product->yeasts.at(i).form == YEAST_FORMS_DRY || product->yeasts.at(i).form == YEAST_FORMS_DRIED)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
121 item = new QTableWidgetItem(QString("%1 gr").arg(product->yeasts.at(i).inventory * 1000.0, 3, 'f', 2, '0'));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
122 else
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
123 item = new QTableWidgetItem(QString("%1 ml").arg(product->yeasts.at(i).inventory * 1000.0, 3, 'f', 2, '0'));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
124 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
125 if (product->yeasts.at(i).inventory < product->yeasts.at(i).amount)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
126 item->setForeground(QBrush(QColor(Qt::red)));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
127 }
179
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
128 ui->yeastsTable->setItem(i, 10, item);
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
129
305
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
130 if (block_yeast(product->stage, product->yeasts.at(i).use)) {
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
131 ui->yeastsTable->removeCellWidget(i, 11); /* to remove the unneeded button */
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
132 item = new QTableWidgetItem("");
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
133 item->setToolTip(tr("Yeast already used"));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
134 ui->yeastsTable->setItem(i, 11, item);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
135 ui->yeastsTable->removeCellWidget(i, 12);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
136 item = new QTableWidgetItem("");
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
137 item->setToolTip(tr("Yeast already used"));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
138 ui->yeastsTable->setItem(i, 12, item);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
139 } else {
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
140 pWidget = new QWidget();
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
141 QPushButton* btn_dele = new QPushButton();
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
142 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
143 btn_dele->setText(tr("Delete"));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
144 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteYeastRow_clicked()));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
145 pLayout = new QHBoxLayout(pWidget);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
146 pLayout->addWidget(btn_dele);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
147 pLayout->setContentsMargins(5, 0, 5, 0);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
148 pWidget->setLayout(pLayout);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
149 ui->yeastsTable->setCellWidget(i, 11, pWidget);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
150
305
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
151 pWidget = new QWidget();
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
152 QPushButton* btn_edit = new QPushButton();
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
153 btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
154 btn_edit->setText(tr("Edit"));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
155 connect(btn_edit, SIGNAL(clicked()), this, SLOT(editYeastRow_clicked()));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
156 pLayout = new QHBoxLayout(pWidget);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
157 pLayout->addWidget(btn_edit);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
158 pLayout->setContentsMargins(5, 0, 5, 0);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
159 pWidget->setLayout(pLayout);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
160 ui->yeastsTable->setCellWidget(i, 12, pWidget);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
161 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
162 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
166 void EditProduct::initYeast()
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
167 {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
168 ui->est_og4Edit->setValue(product->est_og);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
169 ui->est_fg3Edit->setValue(product->est_fg);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
170 ui->est_abv2Edit->setValue(product->est_abv);
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
171 ui->productionEdit->setDate(product->yeast_prod_date);
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
172 ui->conditionShow->setValue(product->starter_viability);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
173 ui->startersgEdit->setValue(product->starter_sg);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
174 ui->pitchrateEdit->setValue(product->yeast_pitchrate);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
175
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
176 ui->yeastsTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
177
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 299
diff changeset
178 for (int i = 0; i < 3; i++) {
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 299
diff changeset
179 ui->stmethodEdit->addItem(QCoreApplication::translate("YeastStarter", g_yeast_starter[i]));
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
180 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
181 ui->stmethodEdit->setCurrentIndex(product->starter_type);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
182 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
183
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
184
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185 /*
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
186 * Calculate the needed yeast for this batch.
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
187 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188 void EditProduct::calcYeast()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
189 {
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
190 double sg = product->brew_fermenter_sg;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
191 double use_cells;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
192 double needed = 0;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
193 double initcells = 0;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
194 bool maybe_starter = false;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
195
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
196 qDebug() << "calcYeast()";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197 ui->yeastProcedure->setCurrentIndex(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
199 if (sg <= 1.0001 && product->fg > 1.000)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
200 sg = product->fg;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
201 else if (sg <= 1.0001)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
202 sg = product->est_og;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
203 double plato = Utils::sg_to_plato(sg);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
204
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
205 double volume = product->brew_fermenter_volume;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
206 if (volume > 0) {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
207 if (product->brew_fermenter_extrawater > 0)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
208 volume += product->brew_fermenter_extrawater;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
209 } else {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
210 volume = product->batch_size - product->eq_trub_chiller_loss;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
211 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
212
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 if (product->yeasts.size() == 0)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 return; // No yeast in product.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
216 calcViability();
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
217
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218 for (int i = 0; i < product->yeasts.size(); i++) {
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
219 if (product->yeasts.at(i).use == YEAST_USE_PRIMARY) { // Primary
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
220 if (product->yeasts.at(i).form == YEAST_FORMS_DRY) {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
222 * Dry yeast, build the formule with the yeast parameters.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
223 * Based on https://www.lallemandbrewing.com/en/canada/brewers-corner/brewing-tools/pitching-rate-calculator/
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
224 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
225 ui->yeastProcedure->setCurrentIndex(2);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
226 ui->lo_gr_hlEdit->setValue(product->yeasts.at(i).gr_hl_lo);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
227 ui->hi_gr_hlEdit->setValue(product->yeasts.at(i).gr_hl_hi);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
228 ui->lo_sgEdit->setValue(product->yeasts.at(i).sg_lo);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
229 ui->hi_sgEdit->setValue(product->yeasts.at(i).sg_hi);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
230 double og = product->yeasts.at(i).sg_lo;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
231 double f1 = product->yeasts.at(i).gr_hl_lo / 100.0;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
232 double f2 = round(f1 / 5 * 1000000.0) / 1000000.0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
233 double multiplier = (sg <= og) ? f1 : (f1 + f2 * (sg - og) / 0.008);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
234 qDebug() << " sg:" << sg << "og:" << og << "f1:" << f1 << "f2:" << f2 << "multiplier:" << multiplier;
200
bbab7d37d12f Dry yeast use yeast viability. Finished calculate dry yeast. Finished using enum values.
Michiel Broek <mbroek@mbse.eu>
parents: 199
diff changeset
235 double yeast_grams = round(volume * multiplier * 100.0) / product->starter_viability;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
236 double yeast_gr_hl = round((yeast_grams / (volume * 0.01)) * 100.0) / 100.0;
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
237 double pitch_gr_hl = round(((product->yeasts.at(i).amount * 1000.0) / (volume * 0.01)) * 100.0) / 100.0;
200
bbab7d37d12f Dry yeast use yeast viability. Finished calculate dry yeast. Finished using enum values.
Michiel Broek <mbroek@mbse.eu>
parents: 199
diff changeset
238 ui->dry_needShow->setValue(yeast_grams);
bbab7d37d12f Dry yeast use yeast viability. Finished calculate dry yeast. Finished using enum values.
Michiel Broek <mbroek@mbse.eu>
parents: 199
diff changeset
239 ui->dry_pitchrateShow->setValue(yeast_gr_hl);
bbab7d37d12f Dry yeast use yeast viability. Finished calculate dry yeast. Finished using enum values.
Michiel Broek <mbroek@mbse.eu>
parents: 199
diff changeset
240 ui->pitch_grShow->setValue(pitch_gr_hl);
bbab7d37d12f Dry yeast use yeast viability. Finished calculate dry yeast. Finished using enum values.
Michiel Broek <mbroek@mbse.eu>
parents: 199
diff changeset
241 ui->pitch_grShow->setStyleSheet((pitch_gr_hl < yeast_gr_hl) ? "background-color: red":"");
bbab7d37d12f Dry yeast use yeast viability. Finished calculate dry yeast. Finished using enum values.
Michiel Broek <mbroek@mbse.eu>
parents: 199
diff changeset
242
bbab7d37d12f Dry yeast use yeast viability. Finished calculate dry yeast. Finished using enum values.
Michiel Broek <mbroek@mbse.eu>
parents: 199
diff changeset
243 qDebug() << " need" << yeast_grams << "grams, gr/hl:" << yeast_gr_hl << "pitch:" << pitch_gr_hl;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
244 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
245 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
246 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
247 * Liquid, slant, culture etc.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
248 * pitchrate see https://www.brewersfriend.com/yeast-pitch-rate-and-starter-calculator/
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
249 * and http://braukaiser.com/blog/blog/2012/11/03/estimating-yeast-growth/
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
250 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
251 ui->yeastProcedure->setCurrentIndex(1);
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
252 if (product->yeast_pitchrate == 0) {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
253 /*
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
254 * No pitchrate yet, do a educated guess ..
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
255 */
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
256 if (product->yeasts.at(i).type == YEAST_TYPES_LAGER) {
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
257 product->yeast_pitchrate = 1.5;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
258 if (sg > 1.060)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
259 product->yeast_pitchrate = 2.0;
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
260 } else if (product->yeasts.at(i).type == YEAST_TYPES_KVEIK) { // Real Kveik
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
261 product->yeast_pitchrate = 0.075;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
262 } else {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
263 product->yeast_pitchrate = 0.75;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
264 if (sg > 1.060)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
265 product->yeast_pitchrate = 1.0;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
266 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
267 is_changed();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
268 ui->pitchrateEdit->setValue(product->yeast_pitchrate);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
269 }
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
270
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
271 initcells = (product->yeasts.at(i).cells / 1000000) * product->yeasts.at(i).amount * (product->starter_viability / 100.0);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
272 if (product->yeasts.at(i).form == YEAST_FORMS_LIQUID)
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
273 initcells = (product->yeasts.at(i).cells / 1000000000) * product->yeasts.at(i).amount * (product->starter_viability / 100.0);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
274
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
275 needed = round(product->yeast_pitchrate * volume * plato * 10.0) / 10.0;
199
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
276 ui->neededShow->setValue(needed);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
277 if (needed > initcells) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
278 maybe_starter = true;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
279 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
280
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
281 qDebug() << " pitchrate:" << product->yeast_pitchrate << "needed:" << needed << "initcells:" << initcells << "starter" << maybe_starter;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
282 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
283 break;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
284 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
285 }
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
286
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
287 if (maybe_starter != product->starter_enable) {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
288 product->starter_enable = maybe_starter;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
289 qDebug() << " Set starter enable" << maybe_starter;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
290 is_changed();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
291 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
292
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
293 if (product->starter_enable) {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
294 qDebug() << " Starter calculate..";
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
295
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
296 const QStringList labels({tr("Method"), tr("Volume"), tr("Inj. factor"), tr("New cells"), tr("Total cells"), tr("Grow factor"), "" });
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
297 ui->starterTable->show();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
298 ui->starterTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
299 ui->starterTable->clear();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
300 ui->starterTable->setColumnCount(7);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
301 ui->starterTable->setRowCount(0);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
302 ui->starterTable->setColumnWidth(0, 130); /* Method */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
303 ui->starterTable->setColumnWidth(1, 90); /* Volume */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
304 ui->starterTable->setColumnWidth(2, 90); /* Inj. factor */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
305 ui->starterTable->setColumnWidth(3, 90); /* New cells */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
306 ui->starterTable->setColumnWidth(4, 90); /* Total cells */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
307 ui->starterTable->setColumnWidth(5, 90); /* Grow factor */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
308 ui->starterTable->setColumnWidth(6, 30); /* Edit button */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
309 ui->starterTable->setHorizontalHeaderLabels(labels);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
310 calcSteps(product->starter_type, initcells, needed);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
311 } else {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
312 ui->starterTable->hide();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
313 }
395
7212b980a527 Added Bitterness Unit to Real Extract unit calculation and display. In product use final values if possible for the BU:GU and BU:RE calculations depending on the product stage.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
314 calcBU();
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
315 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
316
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
317
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
318 /*
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
319 * http://braukaiser.com/blog/blog/2012/11/03/estimating-yeast-growth/
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
320 *
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
321 * stype: 0=stirred, 1=shaken, 2=simple
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
322 * totcells: initial cells
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
323 * egrams: gram extract
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
324 */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
325 double EditProduct::getGrowthRate(int stype, double totcells, double egrams)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
326 {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
327 /* Cells per grams extract (B/g) */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
328 double cpe = totcells / egrams;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
329
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
330 if (cpe > 3.5)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
331 return 0; // no growth
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
332 if (stype == STARTERS_SIMPLE)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
333 return 0.4; // simple starter
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
334 if (stype == STARTERS_SHAKEN)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
335 return 0.62; // shaken starter
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
336 if (cpe <= 1.4) // stirred starter
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
337 return 1.4;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
338 return 2.33 - (.67 * cpe);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
339 };
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
340
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
341
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
342 StepResult EditProduct::calcStep(double svol, int stype, double start)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
343 {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
344 StepResult res;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
345 double gperpoint = 2.72715; //number of grams of extract per point of starter gravity per liter
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
346 double irate = round(start / svol * 10000.0) / 10.0;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
347 double egrams = (product->starter_sg - 1) * svol * gperpoint;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
348 double grate = getGrowthRate(stype, start, egrams);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
349 double ncells = round(egrams * grate * 10.0) / 10.0;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
350 double totcells = ncells + start;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
351
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
352 res.svol = svol;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
353 res.irate = irate;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
354 res.ncells = ncells;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
355 res.totcells = totcells;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
356 res.growf = round((ncells / start) * 100.0) / 100.0;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
357 qDebug() << " calcStep(" << svol << "," << stype << "," << start << ") irate" << irate
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
358 << "ncells" << res.ncells << "totcells" << res.totcells << "growf" << res.growf;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
359 return res;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
360 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
361
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
362
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
363 /*
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
364 * Calculate all starter steps.
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
365 * stype: final starter type: 0 = stirred, 1 = shaked, 2 = simple.
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
366 * start: initial cells in billions
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
367 * needed: needed cells in billions
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
368 *
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
369 * result: all values updated.
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
370 */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
371 void EditProduct::calcSteps(int stype, double start, double needed)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
372 {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
373 int i, step, svol;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
374 int lasti = 0;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
375 /* Erlenmeyer sizes */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
376 const int uvols[] { 20, 40, 60, 80, 100, 150, 200, 250, 375, 500, 625, 750, 875, 1000, 1250, 1500, 2000, 2500, 3000, 4000, 5000 };
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
377 int mvols = sizeof(uvols);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
378 StepResult result;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
379 QTableWidgetItem *item;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
380 QWidget* pWidget;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
381 QHBoxLayout* pLayout;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
382 double tcells = start;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
383 QIcon iconT;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
384
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
385 iconT.addFile(QString::fromUtf8(":/icons/silk/pencil.png"), QSize(), QIcon::Normal, QIcon::Off);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
386
196
f7954f2d4451 Internal product record stores the starter steps in array format.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
387 if ((product->prop_volume[0] + product->prop_volume[1] + product->prop_volume[2] + product->prop_volume[3]) == 0) {
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
388 /*
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
389 * Auto calculate the starter.
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
390 */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
391 qDebug() << " calcSteps() auto";
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
392
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
393 if (start > needed)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
394 return;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
395
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
396 for (step = 1; step < 5; step++) {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
397 qDebug() << " step" << step;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
398
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
399 for (i = lasti; i <= mvols; i++) {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
400 lasti = i;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
401 svol = uvols[lasti];
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
402 result = calcStep(svol, stype, tcells);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
403 if (result.irate < 25) {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
404 // inocculation rate too low, backup one step and break out.
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
405 lasti = i - 1;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
406 svol = uvols[lasti];
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
407 result = calcStep(svol, stype, tcells);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
408 break;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
409 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
410 if (result.totcells > needed || i == mvols) { // hit the target or loops done
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
411 break;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
412 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
413 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
414 ui->starterTable->setRowCount(step);
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 299
diff changeset
415 item = new QTableWidgetItem(QCoreApplication::translate("YeastStarter", g_yeast_starter[stype]));
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
416 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
417 ui->starterTable->setItem(step -1, 0, item);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
418
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
419 item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
420 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
421 ui->starterTable->setItem(step -1, 1, item);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
422
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
423 item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0'));
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
424 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
199
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
425 if ((result.irate < 25) || (result.irate > 100))
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
426 item->setForeground(QBrush(QColor(Qt::red)));
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
427 ui->starterTable->setItem(step -1, 2, item);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
428
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
429 item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0'));
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
430 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
431 ui->starterTable->setItem(step -1, 3, item);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
432
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
433 item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0'));
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
434 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
199
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
435 item->setForeground(QBrush(QColor((result.totcells > needed) ? Qt::green:Qt::red)));
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
436 ui->starterTable->setItem(step -1, 4, item);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
437
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
438 item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0'));
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
439 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
199
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
440 if (result.growf < 1)
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
441 item->setForeground(QBrush(QColor(Qt::red)));
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
442 if ((stype > 0) && (result.growf > 3))
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
443 item->setForeground(QBrush(QColor(Qt::red)));
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
444 ui->starterTable->setItem(step -1, 5, item);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
445
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
446 pWidget = new QWidget();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
447 QToolButton* btn_edit = new QToolButton();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
448 btn_edit->setObjectName(QString("%1").arg(step - 1)); /* Send row with the button */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
449 btn_edit->setIcon(iconT);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
450 connect(btn_edit, SIGNAL(clicked()), this, SLOT(yeast_starter_edit_clicked()));
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
451 pLayout = new QHBoxLayout(pWidget);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
452 pLayout->addWidget(btn_edit);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
453 pLayout->setContentsMargins(5, 0, 5, 0);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
454 pWidget->setLayout(pLayout);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
455 ui->starterTable->setCellWidget(step -1, 6, pWidget);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
456
196
f7954f2d4451 Internal product record stores the starter steps in array format.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
457 product->prop_type[step -1] = product->starter_type;
f7954f2d4451 Internal product record stores the starter steps in array format.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
458 product->prop_volume[step -1] = result.svol / 1000.0;
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
459
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
460 tcells = result.totcells;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
461 if (result.totcells > needed) // Hit the target
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
462 return;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
463 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
464
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
465 } else {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
466 /*
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
467 * Recalculate the starter.
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
468 */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
469 qDebug() << " calcSteps() recalculate";
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
470
199
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
471 for (step = 0; step < 4; step++) {
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
472 if (product->prop_volume[step] > 0) {
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
473 result = calcStep(product->prop_volume[step] * 1000, product->prop_type[step], tcells);
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
474 ui->starterTable->setRowCount(step + 1);
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 299
diff changeset
475 item = new QTableWidgetItem(QCoreApplication::translate("YeastStarter", g_yeast_starter[product->prop_type[step]]));
199
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
476 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
477 ui->starterTable->setItem(step, 0, item);
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
478
199
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
479 item = new QTableWidgetItem(QString("%1").arg(result.svol / 1000.0, 4, 'f', 3, '0')); // To liters
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
480 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
481 ui->starterTable->setItem(step, 1, item);
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
482
199
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
483 item = new QTableWidgetItem(QString("%1").arg(result.irate, 2, 'f', 1, '0'));
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
484 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
485 if ((result.irate < 25) || (result.irate > 100))
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
486 item->setForeground(QBrush(QColor(Qt::red)));
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
487 ui->starterTable->setItem(step, 2, item);
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
488
199
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
489 item = new QTableWidgetItem(QString("%1").arg(result.ncells, 2, 'f', 1, '0'));
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
490 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
491 ui->starterTable->setItem(step, 3, item);
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
492
199
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
493 item = new QTableWidgetItem(QString("%1").arg(result.totcells, 2, 'f', 1, '0'));
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
494 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
495 item->setForeground(QBrush(QColor((result.totcells > needed) ? Qt::green:Qt::red)));
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
496 ui->starterTable->setItem(step, 4, item);
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
497
199
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
498 item = new QTableWidgetItem(QString("%1").arg(result.growf, 3, 'f', 2, '0'));
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
499 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
500 if (result.growf < 1)
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
501 item->setForeground(QBrush(QColor(Qt::red)));
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
502 if ((stype > 0) && (result.growf > 3))
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
503 item->setForeground(QBrush(QColor(Qt::red)));
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
504 ui->starterTable->setItem(step, 5, item);
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
505
199
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
506 pWidget = new QWidget();
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
507 QToolButton* btn_edit = new QToolButton();
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
508 btn_edit->setObjectName(QString("%1").arg(step)); /* Send row with the button */
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
509 btn_edit->setIcon(iconT);
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
510 connect(btn_edit, SIGNAL(clicked()), this, SLOT(yeast_starter_edit_clicked()));
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
511 pLayout = new QHBoxLayout(pWidget);
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
512 pLayout->addWidget(btn_edit);
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
513 pLayout->setContentsMargins(5, 0, 5, 0);
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
514 pWidget->setLayout(pLayout);
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
515 ui->starterTable->setCellWidget(step, 6, pWidget);
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
516
199
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
517 tcells = result.totcells;
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
518 if (result.totcells > needed) { // Hit the target
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
519 for (int i = step + 1; i < 4; i++) {
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
520 product->prop_volume[i] = 0;
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
521 product->prop_type[i] = 0;
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
522 }
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
523 return;
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
524 } else if ((step < 3) && (product->prop_volume[step + 1] == 0)) { // Extra step needed, start with the same size.
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
525 product->prop_volume[step + 1] = product->prop_volume[step];
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
526 product->prop_type[step + 1] = product->prop_type[step];
59b0bdbb2f9f Added field to show the needed cells. Colors in the starter table for good and error results.
Michiel Broek <mbroek@mbse.eu>
parents: 198
diff changeset
527 }
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
528 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
529 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
530 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
531 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
532
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
533
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
534 void EditProduct::calcViability()
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
535 {
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
536 double vpm = 1.00;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
537 double max = 100;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
538
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
539 for (int i = 0; i < product->yeasts.size(); i++) {
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
540 if (product->yeasts.at(i).use == YEAST_USE_PRIMARY) {
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
541 if (product->yeasts.at(i).form == YEAST_FORMS_LIQUID) {
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
542 vpm = 0.80;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
543 max = 97;
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
544 if (product->yeasts.at(i).laboratory == "White Labs") { // PurePitch
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
545 vpm = 0.95;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
546 max = 100;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
547 }
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
548 } else if (product->yeasts.at(i).form == YEAST_FORMS_DRY) {
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
549 vpm = 0.998;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
550 max = 100;
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
551 } else if (product->yeasts.at(i).form == YEAST_FORMS_DRIED) { // dried kveik
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
552 vpm = 0.92;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
553 max = 100;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
554 } else { // Slant, Culture, Frozen, Bottle
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
555 vpm = 0.99;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
556 max = 97;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
557 }
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
558 }
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
559 }
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
560 qDebug() << "calcViability vpm:" << vpm << "max:" << max;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
561
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
562 double base = max;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
563
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
564 /*
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
565 * Calculate time days before today. If the date is cleared,
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
566 * the result is 0 days. Dates in the future are ignored.
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
567 */
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
568 int timeDiff = product->yeast_prod_date.daysTo(QDate::currentDate());
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
569 if (timeDiff < 0)
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
570 timeDiff == 0;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
571
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
572 double degrade = 1 - ((1 - vpm) / 30.41); // viability degradation per day.
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
573 for (int i = 0; i < timeDiff; i++) {
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
574 base = base * degrade;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
575 }
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
576 if (base > max)
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
577 base = max;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
578 base = round(base);
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
579 product->starter_viability = base;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
580 ui->conditionShow->setValue(product->starter_viability);
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
581 qDebug() << "age" << timeDiff << "degrade" << degrade << "base" << base ;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
582 }
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
583
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
584
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
585 void EditProduct::yeast_prod_date_changed(QDate val)
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
586 {
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
587 product->yeast_prod_date = ui->productionEdit->nullDate();
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
588 qDebug() << "yeast_prod_date_changed" << val << product->yeast_prod_date;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
589 calcViability();
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
590 calcYeast();
202
49ec4fdee5a6 Added mash steps pH and SG values.
Michiel Broek <mbroek@mbse.eu>
parents: 201
diff changeset
591 is_changed();
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
592 }
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
593
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
594
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
595 void EditProduct::yeast_prod_date_clear()
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
596 {
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
597 product->yeast_prod_date = QDate();
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
598 ui->productionEdit->setDate(QDate());
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
599 }
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
600
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
601
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
602 void EditProduct::yeast_prod_date_today()
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
603 {
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
604 product->yeast_prod_date = QDate::currentDate();
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
605 ui->productionEdit->setDate(QDate::currentDate());
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
606 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
607
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
608
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
609 void EditProduct::yeast_method_changed(int val)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
610 {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
611 qDebug() << "yeast_method_changed" << val;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
612 product->starter_type = val;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
613 calcYeast();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
614 is_changed();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
615 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
616
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
617
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
618 void EditProduct::yeast_starter_sg_changed(double val)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
619 {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
620 qDebug() << "yeast_starter_sg_changed" << val;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
621 product->starter_sg = val;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
622 calcYeast();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
623 is_changed();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
624 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
625
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
626
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
627 void EditProduct::yeast_pitchrate_button_clicked()
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
628 {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
629 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
630
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
631
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
632 void EditProduct::yeast_starter_edit_clicked()
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
633 {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
634 QToolButton *pb = qobject_cast<QToolButton *>(QObject::sender());
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
635 int row = pb->objectName().toInt();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
636 qDebug() << "yeast_starter_edit_clicked" << row;
196
f7954f2d4451 Internal product record stores the starter steps in array format.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
637
197
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
638 QDialog* dialog = new QDialog(this);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
639 dialog->resize(338, 140);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
640 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
641 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
642 buttonBox->setGeometry(QRect(30, 90, 271, 32));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
643 buttonBox->setLayoutDirection(Qt::LeftToRight);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
644 buttonBox->setOrientation(Qt::Horizontal);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
645 buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
646 buttonBox->setCenterButtons(true);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
647
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
648 QLabel *typeLabel = new QLabel(dialog);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
649 typeLabel->setObjectName(QString::fromUtf8("typeLabel"));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
650 typeLabel->setText(tr("Start step type:"));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
651 typeLabel->setGeometry(QRect(10, 10, 141, 20));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
652 typeLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
653 QLabel *volLabel = new QLabel(dialog);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
654 volLabel->setObjectName(QString::fromUtf8("volLabel"));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
655 volLabel->setText(tr("Starter step volume:"));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
656 volLabel->setGeometry(QRect(10, 40, 141, 20));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
657 volLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
658
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
659 QComboBox *typeEdit = new QComboBox(dialog);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
660 typeEdit->setObjectName(QString::fromUtf8("typeEdit"));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
661 typeEdit->setGeometry(QRect(160, 10, 121, 23));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
662 typeEdit->addItem(tr("Stirred"));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
663 typeEdit->addItem(tr("Shaken"));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
664 typeEdit->addItem(tr("Simple"));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
665 typeEdit->setCurrentIndex(product->prop_type[row]);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
666
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
667 QDoubleSpinBox *volEdit = new QDoubleSpinBox(dialog);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
668 volEdit->setObjectName(QString::fromUtf8("volEdit"));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
669 volEdit->setGeometry(QRect(160, 40, 121, 24));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
670 volEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
671 volEdit->setAccelerated(true);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
672 volEdit->setDecimals(3);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
673 volEdit->setSingleStep(0.01);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
674 volEdit->setValue(product->prop_volume[row]);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
675 volEdit->setMaximum(5);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
676
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
677 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
678 connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
679
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
680 dialog->setModal(true);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
681 dialog->exec();
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
682 if (dialog->result() == QDialog::Rejected) {
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
683 qDebug() << "reject";
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
684 } else {
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
685 product->prop_type[row] = typeEdit->currentIndex();
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
686 product->prop_volume[row] = volEdit->value();
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
687 qDebug() << "accept";
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
688 calcYeast();
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
689 is_changed();
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
690 }
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
691
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
692 disconnect(buttonBox, nullptr, nullptr, nullptr);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
693 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
694
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
695
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
696 void EditProduct::addYeastRow_clicked()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
697 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
698 Yeasts newy;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
699
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
700 qDebug() << "Add yeast row";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
701
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
702 for (int i = 0; i < product->yeasts.size(); i++) {
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
703 if (product->yeasts.at(i).amount == 0)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
704 return; // Add only one at a time.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
705 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
706
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
707 newy.name = "Select one";
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
708 newy.laboratory = "";
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
709 newy.product_id = "";
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
710 newy.amount = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
711 newy.type = YEAST_TYPES_ALE;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
712 newy.form = YEAST_FORMS_LIQUID;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
713 newy.min_temperature = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
714 newy.max_temperature = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
715 newy.flocculation = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
716 newy.attenuation = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
717 newy.cells = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
718 newy.tolerance = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
719 newy.inventory = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
720 newy.use = YEAST_USE_PRIMARY;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
721 newy.sta1 = false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
722 newy.bacteria = false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
723 newy.harvest_top = false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
724 newy.harvest_time = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
725 newy.pitch_temperature = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
726 newy.pofpos = false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
727 newy.zymocide = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
728 newy.gr_hl_lo = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
729 newy.sg_lo = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
730 newy.gr_hl_hi = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
731 newy.sg_hi = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
732 newy.cost = 0;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
733
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
734 product->yeasts.append(newy);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
735 emit refreshAll();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
736 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
737
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
738
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
739 void EditProduct::deleteYeastRow_clicked()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
740 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
741 if (product->locked || product->yeasts.size() < 1)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
742 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
743
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
744 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
745 int row = pb->objectName().toInt();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
746 qDebug() << "Delete yeast row" << row << product->yeasts.size();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
747
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
748 int rc = QMessageBox::warning(this, tr("Delete yeast"), tr("Delete %1").arg(product->yeasts.at(row).name),
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
749 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
750 if (rc == QMessageBox::No)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
751 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
752
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
753 product->yeasts.removeAt(row);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
754 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
755 emit refreshAll();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
756 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
757
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
758
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
759 void EditProduct::yeast_amount_changed(double val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
760 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
761 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
762
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
763 qDebug() << "yeast_amount_changed()" << product->yeasts_row << val;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
764
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
765 if (product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_LIQUID) {
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
766 product->yeasts[product->yeasts_row].amount = val;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
767 item = new QTableWidgetItem(QString("%1 pack").arg(val, 1, 'f', 0, '0'));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
768 } else if ((product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_DRY) ||
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
769 (product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_DRIED)) {
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
770 product->yeasts[product->yeasts_row].amount = val / 1000.0;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
771 item = new QTableWidgetItem(QString("%1 gr").arg(val, 3, 'f', 2, '0'));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
772 } else {
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
773 product->yeasts[product->yeasts_row].amount = val / 1000.0;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
774 item = new QTableWidgetItem(QString("%1 ml").arg(val, 3, 'f', 2, '0'));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
775 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
776 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
777 ui->yeastsTable->setItem(product->yeasts_row, 9, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
778
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
779 calcYeast();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
780 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
781 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
782
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
783
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
784 void EditProduct::yeast_select_changed(int val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
785 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
786 QSqlQuery query;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
787 bool instock = yinstockEdit->isChecked();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
788 QString w;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
789 QTableWidgetItem *item;
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
790 int oldform = product->yeasts.at(product->yeasts_row).form;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
791
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
792 if (val < 1)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
793 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
794
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
795 qDebug() << "yeast_select_changed()" << product->yeasts_row << val << instock;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
796
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
797 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
798 * Search the yeast pointed by the index and instock flag.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
799 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
800 QString sql = "SELECT name,laboratory,product_id,type,form,min_temperature,max_temperature,flocculation,attenuation,"
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
801 "cells,tolerance,sta1,bacteria,harvest_top,harvest_time,pitch_temperature,pofpos,zymocide,"
299
8021e09ab6a3 Fixed select yeasts in recipes and poducts.
Michiel Broek <mbroek@mbse.eu>
parents: 284
diff changeset
802 "gr_hl_lo,sg_lo,gr_hl_hi,sg_hi,cost,inventory FROM inventory_yeasts ";
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
803 if (instock)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
804 sql.append("WHERE inventory > 0 ");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
805 sql.append("ORDER BY laboratory,product_id,name");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
806 query.prepare(sql);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
807 query.exec();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
808 query.first();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
809 for (int i = 0; i < (val - 1); i++) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
810 query.next();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
811 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
812 qDebug() << "found" << query.value(0).toString() << query.value(2).toString();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
813
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
814 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
815 * Replace the yeast record contents
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
816 */
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
817 product->yeasts[product->yeasts_row].name = query.value(0).toString();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
818 product->yeasts[product->yeasts_row].laboratory = query.value(1).toString();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
819 product->yeasts[product->yeasts_row].product_id = query.value(2).toString();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
820 product->yeasts[product->yeasts_row].type = query.value(3).toInt();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
821 product->yeasts[product->yeasts_row].form = query.value(4).toInt();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
822 product->yeasts[product->yeasts_row].min_temperature = query.value(5).toDouble();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
823 product->yeasts[product->yeasts_row].max_temperature = query.value(6).toDouble();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
824 product->yeasts[product->yeasts_row].flocculation = query.value(7).toInt();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
825 product->yeasts[product->yeasts_row].attenuation = query.value(8).toDouble();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
826 product->yeasts[product->yeasts_row].cells = query.value(9).toDouble();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
827 product->yeasts[product->yeasts_row].tolerance = query.value(10).toDouble();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
828 product->yeasts[product->yeasts_row].sta1 = query.value(11).toInt() ? true:false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
829 product->yeasts[product->yeasts_row].bacteria = query.value(12).toInt() ? true:false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
830 product->yeasts[product->yeasts_row].harvest_top = query.value(13).toInt() ? true:false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
831 product->yeasts[product->yeasts_row].harvest_time = query.value(14).toInt();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
832 product->yeasts[product->yeasts_row].pitch_temperature = query.value(15).toDouble();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
833 product->yeasts[product->yeasts_row].pofpos = query.value(16).toInt() ? true:false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
834 product->yeasts[product->yeasts_row].zymocide = query.value(17).toInt();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
835 product->yeasts[product->yeasts_row].gr_hl_lo = query.value(18).toInt();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
836 product->yeasts[product->yeasts_row].sg_lo = query.value(19).toDouble();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
837 product->yeasts[product->yeasts_row].gr_hl_hi = query.value(20).toInt();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
838 product->yeasts[product->yeasts_row].sg_hi = query.value(21).toDouble();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
839 product->yeasts[product->yeasts_row].cost = query.value(22).toDouble();
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
840 product->yeasts[product->yeasts_row].inventory = query.value(23).toDouble();
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
841
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
842 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
843 * Update the visible fields
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
844 */
201
b8232133a12d Fixes for select another yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
845 const QSignalBlocker blocker1(yamountEdit);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
846 ynameEdit->setText(product->yeasts.at(product->yeasts_row).name);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
847 ylaboratoryEdit->setText(product->yeasts.at(product->yeasts_row).laboratory);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
848 yproduct_idEdit->setText(product->yeasts.at(product->yeasts_row).product_id);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
849 if (product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_LIQUID) {
201
b8232133a12d Fixes for select another yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
850 if (oldform != YEAST_FORMS_LIQUID)
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
851 product->yeasts[product->yeasts_row].amount = 1;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
852 yamountEdit->setValue(product->yeasts[product->yeasts_row].amount);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
853 yamountEdit->setDecimals(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
854 yamountEdit->setSingleStep(1.0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
855 yamountLabel->setText(tr("Total packs:"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
856 } else if ((product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_DRY) || (product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_DRIED)) {
201
b8232133a12d Fixes for select another yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
857 if (oldform == YEAST_FORMS_LIQUID)
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
858 product->yeasts[product->yeasts_row].amount = 0.01;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
859 yamountEdit->setValue(product->yeasts[product->yeasts_row].amount * 1000.0);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
860 yamountEdit->setDecimals(1);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
861 yamountEdit->setSingleStep(0.5);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
862 yamountLabel->setText(tr("Amount in gr:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
863 } else {
201
b8232133a12d Fixes for select another yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
864 if (oldform == YEAST_FORMS_LIQUID)
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
865 product->yeasts[product->yeasts_row].amount = 0.01;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
866 yamountEdit->setValue(product->yeasts[product->yeasts_row].amount * 1000.0);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
867 yamountEdit->setDecimals(1);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
868 yamountEdit->setSingleStep(0.5);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
869 yamountLabel->setText(tr("Amount in ml:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
870 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
871
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
872 ui->yeastsTable->setItem(product->yeasts_row, 0, new QTableWidgetItem(product->yeasts.at(product->yeasts_row).name));
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
873 ui->yeastsTable->setItem(product->yeasts_row, 1, new QTableWidgetItem(product->yeasts.at(product->yeasts_row).laboratory));
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
874 ui->yeastsTable->setItem(product->yeasts_row, 2, new QTableWidgetItem(product->yeasts.at(product->yeasts_row).product_id));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
875
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 299
diff changeset
876 item = new QTableWidgetItem(QCoreApplication::translate("YeastForm", g_yeast_forms[product->yeasts.at(product->yeasts_row).form]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
877 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
878 ui->yeastsTable->setItem(product->yeasts_row, 3, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
879
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
880 item = new QTableWidgetItem(QString("%1").arg(product->yeasts.at(product->yeasts_row).min_temperature, 2, 'f', 1, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
881 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
882 ui->yeastsTable->setItem(product->yeasts_row, 5, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
883
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
884 item = new QTableWidgetItem(QString("%1").arg(product->yeasts.at(product->yeasts_row).max_temperature, 2, 'f', 1, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
885 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
886 ui->yeastsTable->setItem(product->yeasts_row, 6, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
887
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
888 item = new QTableWidgetItem(QString("%1").arg(product->yeasts.at(product->yeasts_row).tolerance, 2, 'f', 1, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
889 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
890 ui->yeastsTable->setItem(product->yeasts_row, 7, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
891
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
892 item = new QTableWidgetItem(QString("%1").arg(product->yeasts.at(product->yeasts_row).attenuation, 2, 'f', 1, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
893 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
894 ui->yeastsTable->setItem(product->yeasts_row, 8, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
895
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
896 if (product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_LIQUID)
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
897 item = new QTableWidgetItem(QString("%1 pack").arg(product->yeasts.at(product->yeasts_row).amount, 1, 'f', 0, '0'));
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
898 else if (product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_DRY || product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_DRIED)
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
899 item = new QTableWidgetItem(QString("%1 gr").arg(product->yeasts.at(product->yeasts_row).amount * 1000.0, 3, 'f', 2, '0'));
201
b8232133a12d Fixes for select another yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
900 else
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
901 item = new QTableWidgetItem(QString("%1 ml").arg(product->yeasts.at(product->yeasts_row).amount * 1000.0, 3, 'f', 2, '0'));
201
b8232133a12d Fixes for select another yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
902 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
b8232133a12d Fixes for select another yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
903 ui->yeastsTable->setItem(product->yeasts_row, 9, item);
b8232133a12d Fixes for select another yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
904
b8232133a12d Fixes for select another yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
905 //calcYeast();
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
906 is_changed();
201
b8232133a12d Fixes for select another yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
907 emit refreshAll();
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
908 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
909
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
910
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
911 void EditProduct::yeast_instock_changed(bool val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
912 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
913 QSqlQuery query;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
914
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
915 qDebug() << "yeast_instock_changed()" << product->yeasts_row << val;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
916
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
917 this->yselectEdit->setCurrentIndex(-1);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
918 this->yselectEdit->clear();
299
8021e09ab6a3 Fixed select yeasts in recipes and poducts.
Michiel Broek <mbroek@mbse.eu>
parents: 284
diff changeset
919 QString sql = "SELECT name,laboratory,product_id,inventory FROM inventory_yeasts ";
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
920 if (val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
921 sql.append("WHERE inventory > 0 ");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
922 sql.append("ORDER BY laboratory,product_id,name");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
923 query.prepare(sql);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
924 query.exec();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
925 query.first();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
926 this->yselectEdit->addItem(""); // Start with empty value
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
927 for (int i = 0; i < query.size(); i++) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
928 this->yselectEdit->addItem(query.value(1).toString()+" - "+query.value(2).toString()+" "+query.value(0).toString() +
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
929 QString(" (%1 gr)").arg(query.value(3).toDouble() * 1000.0, 2, 'f', 1, '0'));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
930 query.next();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
931 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
932 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
933
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
934
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
935 void EditProduct::yeast_useat_changed(int val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
936 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
937 qDebug() << "yeast_useat_changed()" << product->yeasts_row << val;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
938
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
939 product->yeasts[product->yeasts_row].use = val;
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 299
diff changeset
940 QTableWidgetItem *item = new QTableWidgetItem(QCoreApplication::translate("YeastUse", g_yeast_use[val]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
941 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
942 ui->yeastsTable->setItem(product->yeasts_row, 5, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
943 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
944 emit refreshAll();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
945 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
946
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
947
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
948 void EditProduct::editYeastRow_clicked()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
949 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
950 QSqlQuery query;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
951
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
952 if (product->locked)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
953 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
954
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
955 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
956 product->yeasts_row = pb->objectName().toInt();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
957 qDebug() << "Edit yeast row" << product->yeasts_row;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
958 Yeasts backup = product->yeasts.at(product->yeasts_row);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
959
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
960 QDialog* dialog = new QDialog(this);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
961 dialog->resize(738, 260);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
962 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
963 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
964 buttonBox->setGeometry(QRect(30, 210, 671, 32));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
965 buttonBox->setLayoutDirection(Qt::LeftToRight);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
966 buttonBox->setOrientation(Qt::Horizontal);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
967 buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
968 buttonBox->setCenterButtons(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
969
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
970 QLabel *nameLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
971 nameLabel->setObjectName(QString::fromUtf8("nameLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
972 nameLabel->setText(tr("Yeast name:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
973 nameLabel->setGeometry(QRect(10, 10, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
974 nameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
975 QLabel *laboratoryLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
976 laboratoryLabel->setObjectName(QString::fromUtf8("laboratoryLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
977 laboratoryLabel->setText(tr("Laboratory:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
978 laboratoryLabel->setGeometry(QRect(10, 40, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
979 laboratoryLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
980 QLabel *product_idLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
981 product_idLabel->setObjectName(QString::fromUtf8("product_idLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
982 product_idLabel->setText(tr("Laboratory:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
983 product_idLabel->setGeometry(QRect(10, 70, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
984 product_idLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
985 QLabel *selectLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
986 selectLabel->setObjectName(QString::fromUtf8("selectLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
987 selectLabel->setText(tr("Select yeast:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
988 selectLabel->setGeometry(QRect(10,100, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
989 selectLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
990 QLabel *instockLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
991 instockLabel->setObjectName(QString::fromUtf8("instockLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
992 instockLabel->setText(tr("In stock:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
993 instockLabel->setGeometry(QRect(525,100, 121, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
994 instockLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
995 yamountLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
996 yamountLabel->setObjectName(QString::fromUtf8("amountLabel"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
997 if (product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_LIQUID)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
998 yamountLabel->setText(tr("Total packs:"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
999 else if ((product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_DRY) || (product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_DRIED))
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1000 yamountLabel->setText(tr("Amount in gr:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1001 else
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1002 yamountLabel->setText(tr("Amount in ml:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1003 yamountLabel->setGeometry(QRect(10, 130, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1004 yamountLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1005 QLabel *useatLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1006 useatLabel->setObjectName(QString::fromUtf8("useatLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1007 useatLabel->setText(tr("Use at:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1008 useatLabel->setGeometry(QRect(10, 160, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1009 useatLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1010
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1011 ynameEdit = new QLineEdit(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1012 ynameEdit->setObjectName(QString::fromUtf8("ynameEdit"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1013 ynameEdit->setText(product->yeasts.at(product->yeasts_row).name);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1014 ynameEdit->setGeometry(QRect(160, 10, 511, 23));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1015 ynameEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1016 ylaboratoryEdit = new QLineEdit(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1017 ylaboratoryEdit->setObjectName(QString::fromUtf8("ylaboratoryEdit"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1018 ylaboratoryEdit->setText(product->yeasts.at(product->yeasts_row).laboratory);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1019 ylaboratoryEdit->setGeometry(QRect(160, 40, 511, 23));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1020 ylaboratoryEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1021 yproduct_idEdit = new QLineEdit(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1022 yproduct_idEdit->setObjectName(QString::fromUtf8("yproduct_idEdit"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1023 yproduct_idEdit->setText(product->yeasts.at(product->yeasts_row).product_id);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1024 yproduct_idEdit->setGeometry(QRect(160, 70, 511, 23));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1025 yproduct_idEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1026 yselectEdit = new QComboBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1027 yselectEdit->setObjectName(QString::fromUtf8("selectEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1028 yselectEdit->setGeometry(QRect(160,100, 371, 23));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1029 yinstockEdit = new QCheckBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1030 yinstockEdit->setObjectName(QString::fromUtf8("yinstockEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1031 yinstockEdit->setGeometry(QRect(655,100, 85, 21));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1032 yinstockEdit->setChecked(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1033 yamountEdit = new QDoubleSpinBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1034 yamountEdit->setObjectName(QString::fromUtf8("yamountEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1035 yamountEdit->setGeometry(QRect(160, 130, 121, 24));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1036 yamountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1037 yamountEdit->setAccelerated(true);
201
b8232133a12d Fixes for select another yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
1038 yamountEdit->setMaximum(10000.0);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1039 if (product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_LIQUID) {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1040 yamountEdit->setDecimals(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1041 yamountEdit->setSingleStep(1.0);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1042 yamountEdit->setValue(product->yeasts.at(product->yeasts_row).amount);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1043 } else if ((product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_DRY) || (product->yeasts.at(product->yeasts_row).form == YEAST_FORMS_DRIED)) {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1044 yamountEdit->setDecimals(1);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1045 yamountEdit->setSingleStep(0.5);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1046 yamountEdit->setValue(product->yeasts.at(product->yeasts_row).amount * 1000.0);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1047 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1048 yamountEdit->setDecimals(1);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1049 yamountEdit->setSingleStep(0.5);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1050 yamountEdit->setValue(product->yeasts.at(product->yeasts_row).amount * 1000.0);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1051 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1052 yamountEdit->setMaximum(1000000000.0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1053 useatEdit = new QComboBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1054 useatEdit->setObjectName(QString::fromUtf8("useatEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1055 useatEdit->setGeometry(QRect(160, 160, 161, 23));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1056 useatEdit->addItem(tr("Primary"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1057 useatEdit->addItem(tr("Secondary"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1058 useatEdit->addItem(tr("Tertiary"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1059 useatEdit->addItem(tr("Bottle"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1060 useatEdit->setCurrentIndex(product->yeasts.at(product->yeasts_row).use);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1061
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1062 yeast_instock_changed(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1063
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1064 connect(yselectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::yeast_select_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1065 connect(yamountEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::yeast_amount_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1066 connect(useatEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::yeast_useat_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1067 connect(yinstockEdit, &QCheckBox::stateChanged, this, &EditProduct::yeast_instock_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1068 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1069 connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1070
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1071 dialog->setModal(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1072 dialog->exec();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1073 if (dialog->result() == QDialog::Rejected) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1074 qDebug() << "reject and rollback";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1075 product->yeasts[product->yeasts_row] = backup;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1076 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1077
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1078 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1079
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1080 disconnect(yselectEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1081 disconnect(yamountEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1082 disconnect(useatEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1083 disconnect(yinstockEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1084 disconnect(buttonBox, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1085
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1086 emit refreshAll();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1087 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1088
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1089
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1090 void EditProduct::adjustYeasts(double factor)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1091 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1092 double amount;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1093
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1094 if (product->yeasts.size() == 0)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1095 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1096
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1097 for (int i = 0; i < product->yeasts.size(); i++) {
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1098 if (product->yeasts.at(i).form == YEAST_FORMS_DRY) { // Only adjust dry yeast
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1099 amount = product->yeasts.at(i).amount * factor;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1100 product->yeasts[i].amount = amount;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1101 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1102 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1103 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1104

mercurial