src/EditProductTab6.cpp

Fri, 03 Feb 2023 11:59:17 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 03 Feb 2023 11:59:17 +0100
changeset 486
f1cc6a30623d
parent 484
ebf7ef31da35
child 487
04c67c9f903c
permissions
-rw-r--r--

Use cells from yeastpack if set to calculate the initcells. Use 90% underpitch to decide for a starter. Hide starter retry label and button if no starter is needed.

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 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
53
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
54 const QStringList labels({tr("Yeast"), tr("Laboratory"), tr("Code"), tr("Type"), tr("Use for"), tr("Min."), tr("Max."),
464
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
55 tr("Tol."), tr("Attn."), tr("STA"), 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
56
464
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
57 ui->yeastsTable->setColumnCount(14);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 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
59 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
60 ui->yeastsTable->setColumnWidth(2, 80); /* Code */
464
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
61 ui->yeastsTable->setColumnWidth(3, 75); /* Type */
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
62 ui->yeastsTable->setColumnWidth(4, 75); /* Usage */
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(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
64 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
65 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
66 ui->yeastsTable->setColumnWidth(8, 50); /* Attenuation */
464
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
67 ui->yeastsTable->setColumnWidth(9, 40); /* STA1 gen */
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
68 ui->yeastsTable->setColumnWidth(10, 80); /* Amount */
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
69 ui->yeastsTable->setColumnWidth(11, 80); /* Stock */
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
70 ui->yeastsTable->setColumnWidth(12, 80); /* Delete */
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
71 ui->yeastsTable->setColumnWidth(13, 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
464
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
106 if (product->yeasts.at(i).use != YEAST_USE_BOTTLE && product->yeasts.at(i).sta1) {
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
107 QWidget *pWidget = new QWidget();
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
108 QLabel *label = new QLabel;
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
109 label->setPixmap(QPixmap(":icons/silk/tick.png"));
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
110 QHBoxLayout *pLayout = new QHBoxLayout(pWidget);
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
111 pLayout->addWidget(label);
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
112 pLayout->setAlignment(Qt::AlignCenter);
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
113 pLayout->setContentsMargins(0, 0, 0, 0);
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
114 pWidget->setLayout(pLayout);
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
115 ui->yeastsTable->setCellWidget(i, 9, pWidget);
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
116 } else {
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
117 ui->yeastsTable->removeCellWidget(i, 9);
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
118 }
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
119
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
120
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
121 if (product->yeasts.at(i).form == YEAST_FORMS_LIQUID)
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
122 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
123 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
124 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
125 else
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
126 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
127 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
464
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
128 ui->yeastsTable->setItem(i, 10, item);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
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 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
132 } 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
133 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
134 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
135 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
136 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
137 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
138 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
139 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
140 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
141 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
142 }
464
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
143 ui->yeastsTable->setItem(i, 11, item);
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
144
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
145 if (block_yeast(product->stage, product->yeasts.at(i).use)) {
464
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
146 ui->yeastsTable->removeCellWidget(i, 12); /* to remove the unneeded button */
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
147 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
148 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
149 ui->yeastsTable->setItem(i, 12, item);
464
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
150 ui->yeastsTable->removeCellWidget(i, 13);
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
151 item = new QTableWidgetItem("");
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
152 item->setToolTip(tr("Yeast already used"));
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
153 ui->yeastsTable->setItem(i, 13, item);
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
154 } 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
155 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
156 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
157 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
158 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
159 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
160 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
161 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
162 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
163 pWidget->setLayout(pLayout);
464
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
164 ui->yeastsTable->setCellWidget(i, 12, pWidget);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165
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
166 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
167 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
168 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
169 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
170 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
171 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
172 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
173 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
174 pWidget->setLayout(pLayout);
464
1fed3ff9a64e Show 0 if afterboil volume is invalid instead of the chiller volume. Added product tab 13. Here the images (beerlabels, brew pictures) for a product will be shown. Resized all product tabs. Added STA1 tickmark in the yeasts table.
Michiel Broek <mbroek@mbse.eu>
parents: 458
diff changeset
175 ui->yeastsTable->setCellWidget(i, 13, pWidget);
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
176 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
181 void EditProduct::initYeast()
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 ui->est_og4Edit->setValue(product->est_og);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
184 ui->est_fg3Edit->setValue(product->est_fg);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
185 ui->est_abv2Edit->setValue(product->est_abv);
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
186 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
187 ui->conditionShow->setValue(product->starter_viability);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
188 ui->startersgEdit->setValue(product->starter_sg);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
189 ui->pitchrateEdit->setValue(product->yeast_pitchrate);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
190
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
191 ui->yeastsTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
192
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 299
diff changeset
193 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
194 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
195 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
196 ui->stmethodEdit->setCurrentIndex(product->starter_type);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
197 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
198
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
199
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 /*
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
201 * 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
202 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
203 void EditProduct::calcYeast()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
204 {
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
205 double sg = product->brew_fermenter_sg;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
206 double use_cells;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
207 double needed = 0;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
208 double initcells = 0;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 bool maybe_starter = false;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 qDebug() << "calcYeast()";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 ui->yeastProcedure->setCurrentIndex(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
214 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
215 sg = product->fg;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
216 else if (sg <= 1.0001)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
217 sg = product->est_og;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
218 double plato = Utils::sg_to_plato(sg);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
219
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
220 double volume = product->brew_fermenter_volume;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
221 if (volume > 0) {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
222 if (product->brew_fermenter_extrawater > 0)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
223 volume += product->brew_fermenter_extrawater;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
224 } else {
458
ac216a75ca9b Renamed trub_chiller_loss fields to trub_loss
Michiel Broek <mbroek@mbse.eu>
parents: 457
diff changeset
225 volume = product->batch_size - product->eq_trub_loss;
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
226 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
227
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
228 if (product->yeasts.size() == 0)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
229 return; // No yeast in product.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
230
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
231 calcViability();
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
232 double dry_amount = 0;
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
233 for (int i = 0; i < product->yeasts.size(); i++) {
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
234 if (product->yeasts.at(i).use == YEAST_USE_PRIMARY && product->yeasts.at(i).form == YEAST_FORMS_DRY) {
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
235 dry_amount += product->yeasts.at(i).amount;
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
236 }
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
237 }
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
238
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
239 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
240 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
241 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
242 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
243 * 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
244 * 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
245 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
246 ui->yeastProcedure->setCurrentIndex(2);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
247 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
248 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
249 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
250 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
251 double og = product->yeasts.at(i).sg_lo;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
252 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
253 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
254 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
255 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
256 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
257 double yeast_gr_hl = round((yeast_grams / (volume * 0.01)) * 100.0) / 100.0;
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
258 double pitch_gr_hl = round(((dry_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
259 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
260 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
261 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
262 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
263
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
264 #ifdef DEBUG_YEAST
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
265 qDebug() << " Need" << yeast_grams << "grams, gr/hl:" << yeast_gr_hl << "pitch:" << pitch_gr_hl;
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
266 #endif
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
267 calcBU();
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
268 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
269 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
270 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
271 * Liquid, slant, culture etc.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
272 * 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
273 * 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
274 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
275 ui->yeastProcedure->setCurrentIndex(1);
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
276 if (product->yeast_pitchrate == 0) {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
277 /*
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
278 * No pitchrate yet, do a educated guess ..
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
279 */
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
280 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
281 product->yeast_pitchrate = 1.5;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
282 if (sg > 1.060)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
283 product->yeast_pitchrate = 2.0;
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
284 } 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
285 product->yeast_pitchrate = 0.075;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
286 } else {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
287 product->yeast_pitchrate = 0.75;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
288 if (sg > 1.060)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
289 product->yeast_pitchrate = 1.0;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
290 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
291 is_changed();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
292 ui->pitchrateEdit->setValue(product->yeast_pitchrate);
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
293 #ifdef DEBUG_YEAST
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
294 qDebug() << " Guessed pitchrate" << product->yeast_pitchrate;
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
295 #endif
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
296 }
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
297
486
f1cc6a30623d Use cells from yeastpack if set to calculate the initcells. Use 90% underpitch to decide for a starter. Hide starter retry label and button if no starter is needed.
Michiel Broek <mbroek@mbse.eu>
parents: 484
diff changeset
298 double cells = product->yeasts.at(i).cells;
f1cc6a30623d Use cells from yeastpack if set to calculate the initcells. Use 90% underpitch to decide for a starter. Hide starter retry label and button if no starter is needed.
Michiel Broek <mbroek@mbse.eu>
parents: 484
diff changeset
299 if (product->yeasts.at(i).yp_cells > 0) { // Use from yeastpack if set
f1cc6a30623d Use cells from yeastpack if set to calculate the initcells. Use 90% underpitch to decide for a starter. Hide starter retry label and button if no starter is needed.
Michiel Broek <mbroek@mbse.eu>
parents: 484
diff changeset
300 cells = product->yeasts.at(i).yp_cells;
f1cc6a30623d Use cells from yeastpack if set to calculate the initcells. Use 90% underpitch to decide for a starter. Hide starter retry label and button if no starter is needed.
Michiel Broek <mbroek@mbse.eu>
parents: 484
diff changeset
301 }
f1cc6a30623d Use cells from yeastpack if set to calculate the initcells. Use 90% underpitch to decide for a starter. Hide starter retry label and button if no starter is needed.
Michiel Broek <mbroek@mbse.eu>
parents: 484
diff changeset
302 initcells = (cells / 1000000) * product->yeasts.at(i).amount * (product->starter_viability / 100.0);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
303 if (product->yeasts.at(i).form == YEAST_FORMS_LIQUID)
486
f1cc6a30623d Use cells from yeastpack if set to calculate the initcells. Use 90% underpitch to decide for a starter. Hide starter retry label and button if no starter is needed.
Michiel Broek <mbroek@mbse.eu>
parents: 484
diff changeset
304 initcells = (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
305
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
306 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
307 ui->neededShow->setValue(needed);
486
f1cc6a30623d Use cells from yeastpack if set to calculate the initcells. Use 90% underpitch to decide for a starter. Hide starter retry label and button if no starter is needed.
Michiel Broek <mbroek@mbse.eu>
parents: 484
diff changeset
308 if ((0.9 * needed) > initcells) { // Allow 90% underpitch without a starter
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
309 maybe_starter = true;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
310 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
311
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
312 #ifdef DEBUG_YEAST
486
f1cc6a30623d Use cells from yeastpack if set to calculate the initcells. Use 90% underpitch to decide for a starter. Hide starter retry label and button if no starter is needed.
Michiel Broek <mbroek@mbse.eu>
parents: 484
diff changeset
313 qDebug() << " Pitchrate:" << product->yeast_pitchrate << "needed:" << 0.9 * needed << "/" << needed << "initcells:" << initcells << "starter" << maybe_starter;
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
314 #endif
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
315 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
316 break;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
317 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
318 }
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
319
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
320 if (maybe_starter != product->starter_enable) {
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
321 if (product->starter_enable && !maybe_starter) {
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
322 #ifdef DEBUG_YEAST
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
323 qDebug() << " Clear obsolete starter";
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
324 #endif
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
325 for (int i = 0; i < 4; i++) {
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
326 product->prop_volume[i] = 0;
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
327 product->prop_type[i] = 0;
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
328 }
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
329 }
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
330 product->starter_enable = maybe_starter;
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
331 #ifdef DEBUG_YEAST
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
332 qDebug() << " Set starter enable" << maybe_starter;
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
333 #endif
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
334 is_changed();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
335 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
336
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
337 if (product->starter_enable) {
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
338 #ifdef DEBUG_YEAST
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
339 qDebug() << " Starter calculate..";
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
340 #endif
195
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 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
343 ui->starterTable->show();
486
f1cc6a30623d Use cells from yeastpack if set to calculate the initcells. Use 90% underpitch to decide for a starter. Hide starter retry label and button if no starter is needed.
Michiel Broek <mbroek@mbse.eu>
parents: 484
diff changeset
344 ui->restartLabel->show();
f1cc6a30623d Use cells from yeastpack if set to calculate the initcells. Use 90% underpitch to decide for a starter. Hide starter retry label and button if no starter is needed.
Michiel Broek <mbroek@mbse.eu>
parents: 484
diff changeset
345 ui->restartButton->show();
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
346 ui->starterTable->setEditTriggers(QAbstractItemView::NoEditTriggers);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
347 ui->starterTable->clear();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
348 ui->starterTable->setColumnCount(7);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
349 ui->starterTable->setRowCount(0);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
350 ui->starterTable->setColumnWidth(0, 130); /* Method */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
351 ui->starterTable->setColumnWidth(1, 90); /* Volume */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
352 ui->starterTable->setColumnWidth(2, 90); /* Inj. factor */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
353 ui->starterTable->setColumnWidth(3, 90); /* New cells */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
354 ui->starterTable->setColumnWidth(4, 90); /* Total cells */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
355 ui->starterTable->setColumnWidth(5, 90); /* Grow factor */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
356 ui->starterTable->setColumnWidth(6, 30); /* Edit button */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
357 ui->starterTable->setHorizontalHeaderLabels(labels);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
358 calcSteps(product->starter_type, initcells, needed);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
359 } else {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
360 ui->starterTable->hide();
486
f1cc6a30623d Use cells from yeastpack if set to calculate the initcells. Use 90% underpitch to decide for a starter. Hide starter retry label and button if no starter is needed.
Michiel Broek <mbroek@mbse.eu>
parents: 484
diff changeset
361 ui->restartLabel->hide();
f1cc6a30623d Use cells from yeastpack if set to calculate the initcells. Use 90% underpitch to decide for a starter. Hide starter retry label and button if no starter is needed.
Michiel Broek <mbroek@mbse.eu>
parents: 484
diff changeset
362 ui->restartButton->hide();
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
363 }
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
364 calcBU();
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
365 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
366
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
367
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 * 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
370 *
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
371 * stype: 0=stirred, 1=shaken, 2=simple
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
372 * totcells: initial cells
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
373 * egrams: gram extract
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
374 */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
375 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
376 {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
377 /* Cells per grams extract (B/g) */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
378 double cpe = totcells / egrams;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
379
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
380 if (cpe > 3.5)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
381 return 0; // no growth
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
382 if (stype == STARTERS_SIMPLE)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
383 return 0.4; // simple starter
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
384 if (stype == STARTERS_SHAKEN)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
385 return 0.62; // shaken starter
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
386 if (cpe <= 1.4) // stirred starter
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
387 return 1.4;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
388 return 2.33 - (.67 * cpe);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
389 };
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
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
392 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
393 {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
394 StepResult res;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
395 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
396 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
397 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
398 double grate = getGrowthRate(stype, start, egrams);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
399 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
400 double totcells = ncells + start;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
401
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
402 res.svol = svol;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
403 res.irate = irate;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
404 res.ncells = ncells;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
405 res.totcells = totcells;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
406 res.growf = round((ncells / start) * 100.0) / 100.0;
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
407 #ifdef DEBUG_YEAST
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
408 qDebug() << " calcStep(" << svol << "," << stype << "," << start << ") irate" << irate
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
409 << "ncells" << res.ncells << "totcells" << res.totcells << "growf" << res.growf;
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
410 #endif
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
411 return res;
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
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
415 /*
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
416 * Calculate all starter steps.
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
417 * 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
418 * start: initial cells in billions
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
419 * needed: needed cells in billions
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
420 *
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
421 * result: all values updated.
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 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
424 {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
425 int i, step, svol;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
426 int lasti = 0;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
427 /* Erlenmeyer sizes */
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
428 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
429 int mvols = sizeof(uvols);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
430 StepResult result;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
431 QTableWidgetItem *item;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
432 QWidget* pWidget;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
433 QHBoxLayout* pLayout;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
434 double tcells = start;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
435 QIcon iconT;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
436
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
437 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
438
196
f7954f2d4451 Internal product record stores the starter steps in array format.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
439 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
440 /*
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
441 * Auto calculate the starter.
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
442 */
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
443 #ifdef DEBUG_YEAST
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
444 qDebug() << " calcSteps() auto";
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
445 #endif
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
446
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
447 if (start > needed)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
448 return;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
449
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
450 for (step = 1; step < 5; step++) {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
451 for (i = lasti; i <= mvols; i++) {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
452 lasti = i;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
453 svol = uvols[lasti];
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
454 result = calcStep(svol, stype, tcells);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
455 if (result.irate < 25) {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
456 // 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
457 lasti = i - 1;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
458 svol = uvols[lasti];
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
459 result = calcStep(svol, stype, tcells);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
460 break;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
461 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
462 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
463 break;
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 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
466 ui->starterTable->setRowCount(step);
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 299
diff changeset
467 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
468 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
469 ui->starterTable->setItem(step -1, 0, item);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
470
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
471 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
472 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
473 ui->starterTable->setItem(step -1, 1, item);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
474
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
475 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
476 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
477 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
478 item->setForeground(QBrush(QColor(Qt::red)));
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
479 ui->starterTable->setItem(step -1, 2, item);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
480
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
481 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
482 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
483 ui->starterTable->setItem(step -1, 3, item);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
484
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
485 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
486 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
487 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
488 ui->starterTable->setItem(step -1, 4, item);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
489
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
490 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
491 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
492 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
493 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
494 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
495 item->setForeground(QBrush(QColor(Qt::red)));
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
496 ui->starterTable->setItem(step -1, 5, item);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
497
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
498 pWidget = new QWidget();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
499 QToolButton* btn_edit = new QToolButton();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
500 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
501 btn_edit->setIcon(iconT);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
502 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
503 pLayout = new QHBoxLayout(pWidget);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
504 pLayout->addWidget(btn_edit);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
505 pLayout->setContentsMargins(5, 0, 5, 0);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
506 pWidget->setLayout(pLayout);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
507 ui->starterTable->setCellWidget(step -1, 6, pWidget);
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
508
196
f7954f2d4451 Internal product record stores the starter steps in array format.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
509 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
510 product->prop_volume[step -1] = result.svol / 1000.0;
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
511 #ifdef DEBUG_YEAST
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
512 qDebug() << " step" << step << "type" << product->prop_type[step -1] << "vol" << product->prop_volume[step -1];
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
513 #endif
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
514
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
515 tcells = result.totcells;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
516 if (result.totcells > needed) // Hit the target
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
517 return;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
518 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
519
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
520 } else {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
521 /*
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
522 * Recalculate the starter.
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
523 */
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
524 #ifdef DEBUG_YEAST
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
525 qDebug() << " calcSteps() recalculate";
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
526 #endif
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
527
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
528 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
529 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
530 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
531 ui->starterTable->setRowCount(step + 1);
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 299
diff changeset
532 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
533 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
534 ui->starterTable->setItem(step, 0, item);
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
535
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
536 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
537 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
538 ui->starterTable->setItem(step, 1, item);
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
539
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
540 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
541 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
542 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
543 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
544 ui->starterTable->setItem(step, 2, item);
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
545
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
546 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
547 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
548 ui->starterTable->setItem(step, 3, item);
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
549
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
550 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
551 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
552 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
553 ui->starterTable->setItem(step, 4, item);
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
554
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
555 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
556 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
557 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
558 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
559 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
560 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
561 ui->starterTable->setItem(step, 5, item);
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
562
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
563 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
564 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
565 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
566 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
567 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
568 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
569 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
570 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
571 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
572 ui->starterTable->setCellWidget(step, 6, pWidget);
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
573
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
574 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
575 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
576 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
577 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
578 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
579 }
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
580 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
581 } 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
582 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
583 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
584 }
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
585 #ifdef DEBUG_YEAST
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
586 qDebug() << " step" << step << "type" << product->prop_type[step] << "vol" << product->prop_volume[step];
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
587 #endif
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
588 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
589 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
590 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
591 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
592
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
593
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
594 void EditProduct::calcViability()
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
595 {
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
596 double vpm = 1.00;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
597 double max = 100;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
598
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
599 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
600 if (product->yeasts.at(i).use == YEAST_USE_PRIMARY) {
483
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
601 qDebug() << "calcViability()" << i << product->yeasts.at(i).yp_uuid << product->yeasts.at(i).yp_package;
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
602 if (! product->yeasts.at(i).yp_uuid.isNull() && (product->yeasts.at(i).yp_uuid.length() == 36)) {
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
603 qDebug() << " valid package vpm:" << product->yeasts.at(i).yp_viability << product->yeasts.at(i).yp_max;
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
604 vpm = product->yeasts.at(i).yp_viability;
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
605 max = product->yeasts.at(i).yp_max;
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
606 } else if (product->yeasts.at(i).form == YEAST_FORMS_LIQUID) { // Fallback to hardcoded values.
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
607 vpm = 0.80;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
608 max = 97;
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
609 if (product->yeasts.at(i).laboratory == "White Labs") { // PurePitch
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
610 /*
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
611 * Purepitch 6th month viability point 80,8%.
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
612 * Purepitch Next Generation 6th month viability point 94,9%.
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
613 */
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
614 vpm = 0.9648; // Purepitch
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
615 //vpm = 0.9914; // Purepitch Next Generation
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
616 max = 100;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
617 }
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
618 } 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
619 vpm = 0.998;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
620 max = 100;
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
621 } 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
622 vpm = 0.92;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
623 max = 100;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
624 } else { // Slant, Culture, Frozen, Bottle
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
625 vpm = 0.99;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
626 max = 97;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
627 }
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
628 }
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
629 }
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
630 #ifdef DEBUG_YEAST
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
631 qDebug() << "calcViability vpm:" << vpm << "max:" << max;
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
632 #endif
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
633
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
634 double base = max;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
635
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
636 /*
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
637 * Calculate time days before today. If the date is cleared,
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
638 * 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
639 */
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
640 int timeDiff = product->yeast_prod_date.daysTo(QDate::currentDate());
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
641 if (timeDiff < 0)
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
642 timeDiff == 0;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
643
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
644 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
645 for (int i = 0; i < timeDiff; i++) {
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
646 base = base * degrade;
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
647 }
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
648 if (base > max)
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
649 base = max;
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
650 product->starter_viability = round(base * 10) / 10;
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
651 ui->conditionShow->setValue(product->starter_viability);
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
652 #ifdef DEBUG_YEAST
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
653 qDebug() << "age" << timeDiff << "degrade" << degrade << "viability" << product->starter_viability;
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
654 #endif
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
655 }
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
656
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
657
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
658 void EditProduct::yeast_prod_date_changed(QDate val)
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
659 {
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
660 product->yeast_prod_date = ui->productionEdit->nullDate();
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
661 calcViability();
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
662 calcYeast();
202
49ec4fdee5a6 Added mash steps pH and SG values.
Michiel Broek <mbroek@mbse.eu>
parents: 201
diff changeset
663 is_changed();
198
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
664 }
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
665
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
666
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
667 void EditProduct::yeast_prod_date_clear()
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
668 {
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
669 product->yeast_prod_date = QDate();
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
670 ui->productionEdit->setDate(QDate());
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
671 }
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
672
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
673
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
674 void EditProduct::yeast_prod_date_today()
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
675 {
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
676 product->yeast_prod_date = QDate::currentDate();
904591820c3d Added yeast viability calculation.
Michiel Broek <mbroek@mbse.eu>
parents: 197
diff changeset
677 ui->productionEdit->setDate(QDate::currentDate());
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
678 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
679
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
680
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
681 void EditProduct::yeast_method_changed(int val)
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
682 {
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
683 #ifdef DEBUG_YEAST
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
684 qDebug() << "yeast_method_changed" << val;
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
685 #endif
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
686 product->starter_type = val;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
687 calcYeast();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
688 is_changed();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
689 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
690
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
691
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
692 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
693 {
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
694 #ifdef DEBUG_YEAST
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
695 qDebug() << "yeast_starter_sg_changed" << val;
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
696 #endif
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
697 product->starter_sg = val;
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
698 calcYeast();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
699 is_changed();
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
700 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
701
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
702
457
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
703 void EditProduct::pitchindex_changed(int val)
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
704 {
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
705 #ifdef DEBUG_YEAST
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
706 qDebug() << "pitchindex_changed" << val;
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
707 #endif
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
708 product->pitch_pitchindex = val;
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
709 }
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
710
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
711
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
712 void EditProduct::pitchrate_changed(double val)
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
713 {
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
714 #ifdef DEBUG_YEAST
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
715 qDebug() << "pitchrate_changed" << val;
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
716 #endif
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
717 product->yeast_pitchrate = val;
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
718 calcYeast();
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
719 is_changed();
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
720 }
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
721
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
722
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
723 void EditProduct::yeast_pitchrate_button_clicked()
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
724 {
456
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
725 #ifdef DEBUG_YEAST
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
726 qDebug() << "yeast_pitchrate_button_clicked";
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
727 #endif
457
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
728 product->pitch_pitchindex = 1;
456
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
729
457
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
730 QDialog* dialog = new QDialog(this);
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
731 dialog->resize(420, 110);
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
732 dialog->setWindowTitle(tr("BMSapp - Pitchrate"));
456
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
733
457
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
734 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
735 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
736 buttonBox->setGeometry(QRect(30, 60, 360, 32));
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
737 buttonBox->setLayoutDirection(Qt::LeftToRight);
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
738 buttonBox->setOrientation(Qt::Horizontal);
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
739 buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
740 buttonBox->setCenterButtons(true);
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
741
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
742 QLabel *typeLabel = new QLabel(dialog);
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
743 typeLabel->setObjectName(QString::fromUtf8("typeLabel"));
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
744 typeLabel->setText(tr("Beer pitch type:"));
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
745 typeLabel->setGeometry(QRect(10, 20, 195, 20));
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
746 typeLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
747
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
748 QComboBox *typeEdit = new QComboBox(dialog);
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
749 typeEdit->setObjectName(QString::fromUtf8("typeEdit"));
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
750 typeEdit->setGeometry(QRect(215, 20, 185, 23));
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
751 typeEdit->setIconSize(QSize(0, 0));
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
752 typeEdit->addItem(tr("0.075 Real Kveik"));
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
753 typeEdit->addItem(tr("0.75 Ale, upto 1.060"));
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
754 typeEdit->addItem(tr("1.0 Ale, above 1.060"));
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
755 typeEdit->addItem(tr("1.5 Lager, upto 1.060"));
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
756 typeEdit->addItem(tr("2.0 Lager, above 1.060"));
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
757 typeEdit->setCurrentIndex(product->pitch_pitchindex);
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
758
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
759 connect(typeEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::pitchindex_changed);
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
760 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
761 connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
762
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
763 dialog->setModal(true);
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
764 dialog->exec();
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
765 if (dialog->result() != QDialog::Rejected) {
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
766 switch (product->pitch_pitchindex) {
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
767 case 0: product->yeast_pitchrate = 0.075; break;
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
768 case 1: product->yeast_pitchrate = 0.75; break;
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
769 case 2: product->yeast_pitchrate = 1.0; break;
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
770 case 3: product->yeast_pitchrate = 1.5; break;
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
771 case 4: product->yeast_pitchrate = 2.0; break;
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
772 }
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
773 ui->pitchrateEdit->setValue(product->yeast_pitchrate); /* Will automatic call calcYeast() and is_changed() */
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
774 }
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
775
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
776 disconnect(typeEdit, nullptr, nullptr, nullptr);
5028c1c4c526 Changed pitchrate field for liquid yeasts to read/write. Added pitchrate select using a QComboBox and added a popup window for that.
Michiel Broek <mbroek@mbse.eu>
parents: 456
diff changeset
777 disconnect(buttonBox, nullptr, nullptr, nullptr);
456
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
778 }
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
779
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
780
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
781 void EditProduct::yeast_retry_button_clicked()
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
782 {
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
783 #ifdef DEBUG_YEAST
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
784 qDebug() << "yeast_retry_button_clicked";
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
785 #endif
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
786
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
787 int rc = QMessageBox::warning(this, tr("Retry starter"), tr("Retry to automatic create starter steps"),
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
788 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
789 if (rc == QMessageBox::No)
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
790 return;
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
791
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
792 for (int i = 0; i < 4; i++) {
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
793 product->prop_volume[i] = 0;
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
794 product->prop_type[i] = product->starter_type;
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
795 }
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
796 calcYeast();
6b10c34f74f5 Added a button to automatic recreate the yeast starter steps. Some code cleanup
Michiel Broek <mbroek@mbse.eu>
parents: 455
diff changeset
797 is_changed();
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
798 }
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
799
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
800
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
801 void EditProduct::yeast_starter_edit_clicked()
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
802 {
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
803 QToolButton *pb = qobject_cast<QToolButton *>(QObject::sender());
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
804 int row = pb->objectName().toInt();
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
805 #ifdef DEBUG_YEAST
195
9887278c4fbe The framework to calculate yeast starters added.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
806 qDebug() << "yeast_starter_edit_clicked" << row;
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
807 #endif
196
f7954f2d4451 Internal product record stores the starter steps in array format.
Michiel Broek <mbroek@mbse.eu>
parents: 195
diff changeset
808
197
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
809 QDialog* dialog = new QDialog(this);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
810 dialog->resize(338, 140);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
811 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
812 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
813 buttonBox->setGeometry(QRect(30, 90, 271, 32));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
814 buttonBox->setLayoutDirection(Qt::LeftToRight);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
815 buttonBox->setOrientation(Qt::Horizontal);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
816 buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
817 buttonBox->setCenterButtons(true);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
818
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
819 QLabel *typeLabel = new QLabel(dialog);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
820 typeLabel->setObjectName(QString::fromUtf8("typeLabel"));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
821 typeLabel->setText(tr("Start step type:"));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
822 typeLabel->setGeometry(QRect(10, 10, 141, 20));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
823 typeLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
824 QLabel *volLabel = new QLabel(dialog);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
825 volLabel->setObjectName(QString::fromUtf8("volLabel"));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
826 volLabel->setText(tr("Starter step volume:"));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
827 volLabel->setGeometry(QRect(10, 40, 141, 20));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
828 volLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
829
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
830 QComboBox *typeEdit = new QComboBox(dialog);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
831 typeEdit->setObjectName(QString::fromUtf8("typeEdit"));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
832 typeEdit->setGeometry(QRect(160, 10, 121, 23));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
833 typeEdit->addItem(tr("Stirred"));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
834 typeEdit->addItem(tr("Shaken"));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
835 typeEdit->addItem(tr("Simple"));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
836 typeEdit->setCurrentIndex(product->prop_type[row]);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
837
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
838 QDoubleSpinBox *volEdit = new QDoubleSpinBox(dialog);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
839 volEdit->setObjectName(QString::fromUtf8("volEdit"));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
840 volEdit->setGeometry(QRect(160, 40, 121, 24));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
841 volEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
842 volEdit->setAccelerated(true);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
843 volEdit->setDecimals(3);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
844 volEdit->setSingleStep(0.01);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
845 volEdit->setValue(product->prop_volume[row]);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
846 volEdit->setMaximum(5);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
847
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
848 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
849 connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
850
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
851 dialog->setModal(true);
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
852 dialog->exec();
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
853 if (dialog->result() != QDialog::Rejected) {
197
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
854 product->prop_type[row] = typeEdit->currentIndex();
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
855 product->prop_volume[row] = volEdit->value();
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
856 calcYeast();
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
857 is_changed();
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
858 }
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
859
6a5e5b3d0fcd Completed the starter step popup editor
Michiel Broek <mbroek@mbse.eu>
parents: 196
diff changeset
860 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
861 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
862
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
863
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
864 void EditProduct::addYeastRow_clicked()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
865 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
866 Yeasts newy;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
867
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
868 #ifdef DEBUG_YEAST
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
869 qDebug() << "Add yeast row";
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
870 #endif
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
871
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
872 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
873 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
874 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
875 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
876
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
877 newy.name = "Select one";
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
878 newy.laboratory = "";
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
879 newy.product_id = "";
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
880 newy.amount = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
881 newy.type = YEAST_TYPES_ALE;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
882 newy.form = YEAST_FORMS_LIQUID;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
883 newy.min_temperature = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
884 newy.max_temperature = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
885 newy.flocculation = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
886 newy.attenuation = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
887 newy.cells = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
888 newy.tolerance = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
889 newy.inventory = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
890 newy.use = YEAST_USE_PRIMARY;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
891 newy.sta1 = false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
892 newy.bacteria = false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
893 newy.harvest_top = false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
894 newy.harvest_time = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
895 newy.pitch_temperature = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
896 newy.pofpos = false;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
897 newy.zymocide = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
898 newy.gr_hl_lo = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
899 newy.sg_lo = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
900 newy.gr_hl_hi = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
901 newy.sg_hi = 0;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
902 newy.cost = 0;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
903
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
904 product->yeasts.append(newy);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
905 emit refreshAll();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
906 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
907
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 void EditProduct::deleteYeastRow_clicked()
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 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
912 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
913
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
914 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
915 int row = pb->objectName().toInt();
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
916 #ifdef DEBUG_YEAST
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
917 qDebug() << "Delete yeast row" << row << product->yeasts.size();
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
918 #endif
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
919
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
920 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
921 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
922 if (rc == QMessageBox::No)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
923 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
924
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
925 product->yeasts.removeAt(row);
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
926 bool primary = false; /* Check if any primary yeast is left */
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
927 for (int i = 0; i < product->yeasts.size(); i++) {
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
928 if (product->yeasts.at(i).use == YEAST_USE_PRIMARY)
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
929 primary = true;
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
930 }
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
931 if (! primary) {
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
932 #ifdef DEBUG_YEAST
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
933 qDebug() << " Clear starter (if any)";
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
934 #endif
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
935 for (int i = 0; i < 4; i++)
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
936 product->prop_volume[i] = 0;
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
937 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
938 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
939 emit refreshAll();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
940 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
941
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
942
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
943 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
944 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
945 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
946
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
947 #ifdef DEBUG_YEAST
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
948 qDebug() << "yeast_amount_changed()" << product->yeasts_row << val;
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
949 #endif
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
950
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
951 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
952 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
953 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
954 } 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
955 (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
956 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
957 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
958 } else {
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
959 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
960 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
961 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
962 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
963 ui->yeastsTable->setItem(product->yeasts_row, 10, item);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
964
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
965 calcYeast();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
966 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
967 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
968
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
969
483
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
970 void EditProduct::yeast_load_packages(QString laboratory, int form)
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
971 {
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
972 QSqlQuery query;
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
973
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
974 /*
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
975 * Clear package and rebuild package select table.
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
976 */
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
977 this->ypackageEdit->setCurrentIndex(-1);
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
978 this->ypackageEdit->clear();
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
979 this->ypackageEdit->addItem(""); // Start with empty value
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
980 query.prepare("SELECT * FROM inventory_yeastpack WHERE laboratory=:laboratory AND form=:form AND valid='1' ORDER BY laboratory,package");
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
981 query.bindValue(":laboratory", laboratory);
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
982 query.bindValue(":form", form);
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
983 qDebug() << " search" << laboratory << form;
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
984 query.exec();
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
985 while (query.next()) {
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
986 this->ypackageEdit->addItem(query.value("laboratory").toString()+" - "+query.value("package").toString());
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
987 qDebug() << " add package" << query.value("laboratory").toString() << query.value("package").toString();
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
988 }
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
989 }
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
990
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
991
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
992 void EditProduct::yeast_package_changed(int val)
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
993 {
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
994 QSqlQuery query;
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
995 int index = 0;
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
996
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
997 #ifdef DEBUG_YEAST
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
998 qDebug() << "yeast_package_changed()" << product->yeasts_row << val;
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
999 #endif
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1000
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1001 /*
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1002 * Scan the packages for result number 'val'
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1003 */
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1004 query.prepare("SELECT * FROM inventory_yeastpack WHERE laboratory=:laboratory AND form=:form AND valid='1' ORDER BY laboratory,package");
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1005 query.bindValue(":laboratory", product->yeasts.at(product->yeasts_row).laboratory);
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1006 query.bindValue(":form", product->yeasts.at(product->yeasts_row).form);
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1007 qDebug() << " search" << product->yeasts.at(product->yeasts_row).laboratory << product->yeasts.at(product->yeasts_row).form;
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1008 query.exec();
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1009 while (query.next()) {
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1010 index++;
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1011 if (index == val) {
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1012 qDebug() << " result" << index << query.value("package").toString();
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1013 product->yeasts[product->yeasts_row].yp_uuid = query.value("uuid").toString();
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1014 product->yeasts[product->yeasts_row].yp_package = query.value("package").toString();
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1015 product->yeasts[product->yeasts_row].yp_cells = query.value("cells").toDouble();
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1016 product->yeasts[product->yeasts_row].yp_viability = query.value("viability").toDouble();
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1017 product->yeasts[product->yeasts_row].yp_max = query.value("max").toInt();
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1018 product->yeasts[product->yeasts_row].yp_size = query.value("size").toDouble();
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1019 is_changed();
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1020 return;
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1021 }
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1022 }
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1023 if (! product->yeasts[product->yeasts_row].yp_uuid.isNull()) {
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1024 /*
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1025 * Clear package
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1026 */
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1027 product->yeasts[product->yeasts_row].yp_uuid = QString();
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1028 product->yeasts[product->yeasts_row].yp_package = QString();
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1029 product->yeasts[product->yeasts_row].yp_cells = product->yeasts[product->yeasts_row].cells;
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1030 product->yeasts[product->yeasts_row].yp_viability = 0.99;
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1031 product->yeasts[product->yeasts_row].yp_max = 100;
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1032 product->yeasts[product->yeasts_row].yp_size = 0.01;
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1033 is_changed();
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1034 qDebug() << " cleared old yp_xxx data";
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1035 }
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1036 qDebug() << " result not found";
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1037 }
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1038
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1039
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1040 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
1041 {
483
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1042 QSqlQuery query;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1043 bool instock = yinstockEdit->isChecked();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1044 QString w;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1045 QTableWidgetItem *item;
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1046 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
1047
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1048 if (val < 1)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1049 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1050
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1051 #ifdef DEBUG_YEAST
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1052 qDebug() << "yeast_select_changed()" << product->yeasts_row << val << instock;
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1053 #endif
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1054
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1055 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1056 * 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
1057 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1058 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
1059 "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
1060 "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
1061 if (instock)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1062 sql.append("WHERE inventory > 0 ");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1063 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
1064 query.prepare(sql);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1065 query.exec();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1066 query.first();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1067 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
1068 query.next();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1069 }
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1070 #ifdef DEBUG_YEAST
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1071 qDebug() << "found" << query.value("name").toString() << query.value("product_id").toString();
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1072 #endif
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1073
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1074 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1075 * Replace the yeast record contents
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1076 */
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1077 product->yeasts[product->yeasts_row].name = query.value("name").toString();
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1078 product->yeasts[product->yeasts_row].laboratory = query.value("laboratory").toString();
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1079 product->yeasts[product->yeasts_row].product_id = query.value("product_id").toString();
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1080 product->yeasts[product->yeasts_row].type = query.value("type").toInt();
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1081 product->yeasts[product->yeasts_row].form = query.value("form").toInt();
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1082 product->yeasts[product->yeasts_row].min_temperature = query.value("min_temperature").toDouble();
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1083 product->yeasts[product->yeasts_row].max_temperature = query.value("max_temperature").toDouble();
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1084 product->yeasts[product->yeasts_row].flocculation = query.value("flocculation").toInt();
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1085 product->yeasts[product->yeasts_row].attenuation = query.value("attenuation").toDouble();
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1086 product->yeasts[product->yeasts_row].cells = query.value("cells").toDouble();
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1087 product->yeasts[product->yeasts_row].tolerance = query.value("tolerance").toDouble();
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1088 product->yeasts[product->yeasts_row].sta1 = query.value("sta1").toInt() ? true:false;
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1089 product->yeasts[product->yeasts_row].bacteria = query.value("bacteria").toInt() ? true:false;
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1090 product->yeasts[product->yeasts_row].harvest_top = query.value("harvest_top").toInt() ? true:false;
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1091 product->yeasts[product->yeasts_row].harvest_time = query.value("harvest_time").toInt();
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1092 product->yeasts[product->yeasts_row].pitch_temperature = query.value("pitch_temperature").toDouble();
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1093 product->yeasts[product->yeasts_row].pofpos = query.value("pofpos").toInt() ? true:false;
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1094 product->yeasts[product->yeasts_row].zymocide = query.value("zymocide").toInt();
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1095 product->yeasts[product->yeasts_row].gr_hl_lo = query.value("gr_hl_lo").toInt();
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1096 product->yeasts[product->yeasts_row].sg_lo = query.value("sg_lo").toDouble();
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1097 product->yeasts[product->yeasts_row].gr_hl_hi = query.value("gr_hl_hi").toInt();
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1098 product->yeasts[product->yeasts_row].sg_hi = query.value("sg_hi").toDouble();
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1099 product->yeasts[product->yeasts_row].cost = query.value("cost").toDouble();
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1100 product->yeasts[product->yeasts_row].inventory = query.value("inventory").toDouble();
482
e13763ec829f Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.
Michiel Broek <mbroek@mbse.eu>
parents: 478
diff changeset
1101 product->yeasts[product->yeasts_row].yp_uuid = QString();
175
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 * Update the visible fields
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1105 */
201
b8232133a12d Fixes for select another yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
1106 const QSignalBlocker blocker1(yamountEdit);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1107 ynameEdit->setText(product->yeasts.at(product->yeasts_row).name);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1108 ylaboratoryEdit->setText(product->yeasts.at(product->yeasts_row).laboratory);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1109 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
1110 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
1111 if (oldform != YEAST_FORMS_LIQUID)
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1112 product->yeasts[product->yeasts_row].amount = 1;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1113 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
1114 yamountEdit->setDecimals(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1115 yamountEdit->setSingleStep(1.0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1116 yamountLabel->setText(tr("Total packs:"));
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
1117 product->yeast_pitchrate = 0;
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1118 } 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
1119 if (oldform == YEAST_FORMS_LIQUID)
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1120 product->yeasts[product->yeasts_row].amount = 0.01;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1121 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
1122 yamountEdit->setDecimals(1);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1123 yamountEdit->setSingleStep(0.5);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1124 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
1125 } else {
201
b8232133a12d Fixes for select another yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
1126 if (oldform == YEAST_FORMS_LIQUID)
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1127 product->yeasts[product->yeasts_row].amount = 0.01;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1128 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
1129 yamountEdit->setDecimals(1);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1130 yamountEdit->setSingleStep(0.5);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1131 yamountLabel->setText(tr("Amount in ml:"));
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
1132 product->yeast_pitchrate = 0;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1133 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1134
482
e13763ec829f Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.
Michiel Broek <mbroek@mbse.eu>
parents: 478
diff changeset
1135 /*
e13763ec829f Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.
Michiel Broek <mbroek@mbse.eu>
parents: 478
diff changeset
1136 * Clear package and rebuild package select table.
e13763ec829f Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.
Michiel Broek <mbroek@mbse.eu>
parents: 478
diff changeset
1137 */
483
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1138 yeast_load_packages(query.value("laboratory").toString(), query.value("form").toInt());
482
e13763ec829f Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.
Michiel Broek <mbroek@mbse.eu>
parents: 478
diff changeset
1139
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1140 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
1141 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
1142 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
1143
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 299
diff changeset
1144 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
1145 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
1146 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
1147
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1148 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
1149 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
1150 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
1151
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1152 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
1153 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
1154 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
1155
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1156 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
1157 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
1158 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
1159
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1160 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
1161 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
1162 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
1163
476
29487eac1183 Fixed replace a yeast field offsets.
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
1164 if (product->yeasts.at(product->yeasts_row).use != YEAST_USE_BOTTLE && product->yeasts.at(product->yeasts_row).sta1) {
29487eac1183 Fixed replace a yeast field offsets.
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
1165 QWidget *pWidget = new QWidget();
29487eac1183 Fixed replace a yeast field offsets.
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
1166 QLabel *label = new QLabel;
29487eac1183 Fixed replace a yeast field offsets.
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
1167 label->setPixmap(QPixmap(":icons/silk/tick.png"));
29487eac1183 Fixed replace a yeast field offsets.
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
1168 QHBoxLayout *pLayout = new QHBoxLayout(pWidget);
29487eac1183 Fixed replace a yeast field offsets.
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
1169 pLayout->addWidget(label);
29487eac1183 Fixed replace a yeast field offsets.
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
1170 pLayout->setAlignment(Qt::AlignCenter);
29487eac1183 Fixed replace a yeast field offsets.
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
1171 pLayout->setContentsMargins(0, 0, 0, 0);
29487eac1183 Fixed replace a yeast field offsets.
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
1172 pWidget->setLayout(pLayout);
29487eac1183 Fixed replace a yeast field offsets.
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
1173 ui->yeastsTable->setCellWidget(product->yeasts_row, 9, pWidget);
29487eac1183 Fixed replace a yeast field offsets.
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
1174 } else {
29487eac1183 Fixed replace a yeast field offsets.
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
1175 ui->yeastsTable->removeCellWidget(product->yeasts_row, 9);
29487eac1183 Fixed replace a yeast field offsets.
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
1176 }
29487eac1183 Fixed replace a yeast field offsets.
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
1177
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1178 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
1179 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
1180 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
1181 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
1182 else
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1183 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
1184 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
476
29487eac1183 Fixed replace a yeast field offsets.
Michiel Broek <mbroek@mbse.eu>
parents: 464
diff changeset
1185 ui->yeastsTable->setItem(product->yeasts_row, 10, item);
201
b8232133a12d Fixes for select another yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
1186
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1187 /*
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1188 * If there is no need for a starter, wipe it.
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1189 */
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1190 bool maybe_starter = false;
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1191 for (int i = 0; i < product->yeasts.size(); i++) {
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1192 if (product->yeasts.at(i).use == YEAST_USE_PRIMARY &&
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1193 ! ((product->yeasts.at(i).form == YEAST_FORMS_DRY) || (product->yeasts.at(i).form == YEAST_FORMS_DRIED)))
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1194 maybe_starter = true;
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1195 }
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1196 if (! maybe_starter) {
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1197 #ifdef DEBUG_YEAST
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1198 qDebug() << " Clear starter (if any)";
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1199 #endif
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1200 for (int i = 0; i < 4; i++)
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1201 product->prop_volume[i] = 0;
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1202 }
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1203
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1204 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1205 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1206
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1207
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1208 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
1209 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1210 QSqlQuery query;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1211
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1212 #ifdef DEBUG_YEAST
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1213 qDebug() << "yeast_instock_changed()" << product->yeasts_row << val;
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1214 #endif
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1215
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1216 this->yselectEdit->setCurrentIndex(-1);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1217 this->yselectEdit->clear();
299
8021e09ab6a3 Fixed select yeasts in recipes and poducts.
Michiel Broek <mbroek@mbse.eu>
parents: 284
diff changeset
1218 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
1219 if (val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1220 sql.append("WHERE inventory > 0 ");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1221 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
1222 query.prepare(sql);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1223 query.exec();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1224 query.first();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1225 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
1226 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
1227 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
1228 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
1229 query.next();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1230 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1231 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1232
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1233
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1234 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
1235 {
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1236 #ifdef DEBUG_YEAST
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1237 qDebug() << "yeast_useat_changed()" << product->yeasts_row << val;
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1238 #endif
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1239
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1240 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
1241 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
1242 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
478
a3653722b0d6 Add dry primary yeasts weights to get a mixed total. Use the parameters from the first and mmost used yeast. Changed in products and recipes. Recalculated WLP purepitch viability and planned next generation purepitch. We need a better way to set these parameters like a packages table. Fixed several yeast edit values due to adding a STA1 column. Removed several unneeded refresh_all() calls as they screwed the sorting of the yeasts during edit. Added STA1 display to recipes. Changed products database starter_viability from integer to float.
Michiel Broek <mbroek@mbse.eu>
parents: 476
diff changeset
1243 ui->yeastsTable->setItem(product->yeasts_row, 4, item);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1244 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1245 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1246
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1247
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1248 void EditProduct::editYeastRow_clicked()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1249 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1250 QSqlQuery query;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1251
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1252 if (product->locked)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1253 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1254
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1255 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
1256 product->yeasts_row = pb->objectName().toInt();
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1257 #ifdef DEBUG_YEAST
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1258 qDebug() << "Edit yeast row" << product->yeasts_row;
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1259 #endif
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1260 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
1261
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1262 QDialog* dialog = new QDialog(this);
482
e13763ec829f Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.
Michiel Broek <mbroek@mbse.eu>
parents: 478
diff changeset
1263 dialog->resize(738, 290);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1264 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1265 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
482
e13763ec829f Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.
Michiel Broek <mbroek@mbse.eu>
parents: 478
diff changeset
1266 buttonBox->setGeometry(QRect(30, 240, 671, 32));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1267 buttonBox->setLayoutDirection(Qt::LeftToRight);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1268 buttonBox->setOrientation(Qt::Horizontal);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1269 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
1270 buttonBox->setCenterButtons(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1271
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1272 QLabel *nameLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1273 nameLabel->setObjectName(QString::fromUtf8("nameLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1274 nameLabel->setText(tr("Yeast name:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1275 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
1276 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
1277 QLabel *laboratoryLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1278 laboratoryLabel->setObjectName(QString::fromUtf8("laboratoryLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1279 laboratoryLabel->setText(tr("Laboratory:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1280 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
1281 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
1282 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
1283 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
1284 product_idLabel->setText(tr("Laboratory:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1285 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
1286 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
1287 QLabel *selectLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1288 selectLabel->setObjectName(QString::fromUtf8("selectLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1289 selectLabel->setText(tr("Select yeast:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1290 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
1291 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
1292 QLabel *instockLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1293 instockLabel->setObjectName(QString::fromUtf8("instockLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1294 instockLabel->setText(tr("In stock:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1295 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
1296 instockLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
482
e13763ec829f Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.
Michiel Broek <mbroek@mbse.eu>
parents: 478
diff changeset
1297 QLabel *packageLabel = new QLabel(dialog);
e13763ec829f Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.
Michiel Broek <mbroek@mbse.eu>
parents: 478
diff changeset
1298 packageLabel->setObjectName(QString::fromUtf8("packageLabel"));
e13763ec829f Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.
Michiel Broek <mbroek@mbse.eu>
parents: 478
diff changeset
1299 packageLabel->setText(tr("Select package:"));
e13763ec829f Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.
Michiel Broek <mbroek@mbse.eu>
parents: 478
diff changeset
1300 packageLabel->setGeometry(QRect(10,130, 141, 20));
e13763ec829f Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.
Michiel Broek <mbroek@mbse.eu>
parents: 478
diff changeset
1301 packageLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1302 yamountLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1303 yamountLabel->setObjectName(QString::fromUtf8("amountLabel"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1304 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
1305 yamountLabel->setText(tr("Total packs:"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1306 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
1307 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
1308 else
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1309 yamountLabel->setText(tr("Amount in ml:"));
482
e13763ec829f Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.
Michiel Broek <mbroek@mbse.eu>
parents: 478
diff changeset
1310 yamountLabel->setGeometry(QRect(10, 160, 141, 20));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1311 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
1312 QLabel *useatLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1313 useatLabel->setObjectName(QString::fromUtf8("useatLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1314 useatLabel->setText(tr("Use at:"));
482
e13763ec829f Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.
Michiel Broek <mbroek@mbse.eu>
parents: 478
diff changeset
1315 useatLabel->setGeometry(QRect(10, 190, 141, 20));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1316 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
1317
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1318 ynameEdit = new QLineEdit(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1319 ynameEdit->setObjectName(QString::fromUtf8("ynameEdit"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1320 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
1321 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
1322 ynameEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1323 ylaboratoryEdit = new QLineEdit(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1324 ylaboratoryEdit->setObjectName(QString::fromUtf8("ylaboratoryEdit"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1325 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
1326 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
1327 ylaboratoryEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1328 yproduct_idEdit = new QLineEdit(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1329 yproduct_idEdit->setObjectName(QString::fromUtf8("yproduct_idEdit"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1330 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
1331 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
1332 yproduct_idEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1333 yselectEdit = new QComboBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1334 yselectEdit->setObjectName(QString::fromUtf8("selectEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1335 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
1336 yinstockEdit = new QCheckBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1337 yinstockEdit->setObjectName(QString::fromUtf8("yinstockEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1338 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
1339 yinstockEdit->setChecked(true);
482
e13763ec829f Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.
Michiel Broek <mbroek@mbse.eu>
parents: 478
diff changeset
1340 ypackageEdit = new QComboBox(dialog);
e13763ec829f Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.
Michiel Broek <mbroek@mbse.eu>
parents: 478
diff changeset
1341 ypackageEdit->setObjectName(QString::fromUtf8("packageEdit"));
e13763ec829f Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.
Michiel Broek <mbroek@mbse.eu>
parents: 478
diff changeset
1342 ypackageEdit->setGeometry(QRect(160,130, 371, 23));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1343 yamountEdit = new QDoubleSpinBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1344 yamountEdit->setObjectName(QString::fromUtf8("yamountEdit"));
482
e13763ec829f Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.
Michiel Broek <mbroek@mbse.eu>
parents: 478
diff changeset
1345 yamountEdit->setGeometry(QRect(160, 160, 121, 24));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1346 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
1347 yamountEdit->setAccelerated(true);
201
b8232133a12d Fixes for select another yeast.
Michiel Broek <mbroek@mbse.eu>
parents: 200
diff changeset
1348 yamountEdit->setMaximum(10000.0);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1349 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
1350 yamountEdit->setDecimals(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1351 yamountEdit->setSingleStep(1.0);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1352 yamountEdit->setValue(product->yeasts.at(product->yeasts_row).amount);
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1353 } 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
1354 yamountEdit->setDecimals(1);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1355 yamountEdit->setSingleStep(0.5);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1356 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
1357 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1358 yamountEdit->setDecimals(1);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1359 yamountEdit->setSingleStep(0.5);
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1360 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
1361 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1362 yamountEdit->setMaximum(1000000000.0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1363 useatEdit = new QComboBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1364 useatEdit->setObjectName(QString::fromUtf8("useatEdit"));
482
e13763ec829f Expanded Yeast edit popup with a Yeast Pack dropdown list. Prepared database product read and write with values for yeast package. They will be stored as json object in the yeast records.
Michiel Broek <mbroek@mbse.eu>
parents: 478
diff changeset
1365 useatEdit->setGeometry(QRect(160, 190, 161, 23));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1366 useatEdit->addItem(tr("Primary"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1367 useatEdit->addItem(tr("Secondary"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1368 useatEdit->addItem(tr("Tertiary"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1369 useatEdit->addItem(tr("Bottle"));
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1370 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
1371
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1372 yeast_instock_changed(true);
483
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1373 yeast_load_packages(product->yeasts.at(product->yeasts_row).laboratory, product->yeasts.at(product->yeasts_row).form);
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1374
484
ebf7ef31da35 Set yeastpack dropdown on yeast edit row start.
Michiel Broek <mbroek@mbse.eu>
parents: 483
diff changeset
1375 /*
ebf7ef31da35 Set yeastpack dropdown on yeast edit row start.
Michiel Broek <mbroek@mbse.eu>
parents: 483
diff changeset
1376 * Try to set the yeastpack dropdown to the selected entry if set.
ebf7ef31da35 Set yeastpack dropdown on yeast edit row start.
Michiel Broek <mbroek@mbse.eu>
parents: 483
diff changeset
1377 */
ebf7ef31da35 Set yeastpack dropdown on yeast edit row start.
Michiel Broek <mbroek@mbse.eu>
parents: 483
diff changeset
1378 int index = 0;
483
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1379 if (! product->yeasts.at(product->yeasts_row).yp_uuid.isNull() && (product->yeasts.at(product->yeasts_row).yp_uuid.length() == 36)) {
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1380 query.prepare("SELECT * FROM inventory_yeastpack WHERE laboratory=:laboratory AND form=:form AND valid='1' ORDER BY laboratory,package");
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1381 query.bindValue(":laboratory", product->yeasts.at(product->yeasts_row).laboratory);
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1382 query.bindValue(":form", product->yeasts.at(product->yeasts_row).form);
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1383 query.exec();
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1384 while (query.next()) {
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1385 index++;
484
ebf7ef31da35 Set yeastpack dropdown on yeast edit row start.
Michiel Broek <mbroek@mbse.eu>
parents: 483
diff changeset
1386 if (query.value("uuid").toString() == product->yeasts.at(product->yeasts_row).yp_uuid) {
ebf7ef31da35 Set yeastpack dropdown on yeast edit row start.
Michiel Broek <mbroek@mbse.eu>
parents: 483
diff changeset
1387 this->ypackageEdit->setCurrentIndex(index);
483
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1388 break;
484
ebf7ef31da35 Set yeastpack dropdown on yeast edit row start.
Michiel Broek <mbroek@mbse.eu>
parents: 483
diff changeset
1389 }
483
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1390 }
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1391 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1392
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1393 connect(yselectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::yeast_select_changed);
483
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1394 connect(ypackageEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::yeast_package_changed);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1395 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
1396 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
1397 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
1398 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
1399 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
1400
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1401 dialog->setModal(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1402 dialog->exec();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1403 if (dialog->result() == QDialog::Rejected) {
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1404 #ifdef DEBUG_YEAST
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1405 qDebug() << "reject and rollback";
455
deea5047be32 Fixed dangling old starter data. Added conditional yeast debug logging.
Michiel Broek <mbroek@mbse.eu>
parents: 454
diff changeset
1406 #endif
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1407 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
1408 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1409
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1410 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1411
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1412 disconnect(yselectEdit, nullptr, nullptr, nullptr);
483
eb0a5f132ea9 Added default load yeastpacks. Added yeast_package_changed signal.
Michiel Broek <mbroek@mbse.eu>
parents: 482
diff changeset
1413 disconnect(ypackageEdit, nullptr, nullptr, nullptr);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1414 disconnect(yamountEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1415 disconnect(useatEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1416 disconnect(yinstockEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1417 disconnect(buttonBox, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1418
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1419 emit refreshAll();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1420 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1421
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1422
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1423 void EditProduct::adjustYeasts(double factor)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1424 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1425 double amount;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1426
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1427 if (product->yeasts.size() == 0)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1428 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1429
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1430 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
1431 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
1432 amount = product->yeasts.at(i).amount * factor;
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 202
diff changeset
1433 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
1434 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1435 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1436 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1437

mercurial