src/EditProductTab4.cpp

Thu, 18 Aug 2022 19:47:28 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 18 Aug 2022 19:47:28 +0200
changeset 399
4b9aaf86094e
parent 398
49cf387e9070
child 413
8ea791d4cab6
permissions
-rw-r--r--

Prompts corrections and updated translations. Minor layout changes so the prompts will fit.

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 4, hops
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 hope 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
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 bool EditProduct::hop_sort_test(const Hops &D1, const Hops &D2)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 {
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
24 if (D1.useat > D2.useat)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 return false;
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
26 if (D1.useat < D2.useat)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 return true;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 /* Same useat moments, test time. */
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
29 if (D1.time < D2.time)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 return false;
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
31 if (D1.time > D2.time)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 return true;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 /* Finally consider the amounts */
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
34 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
35 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37
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
38 bool EditProduct::block_hop(int stage, int useat)
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 {
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 if (stage > PROD_STAGE_BREW && useat < HOP_USEAT_DRY_HOP)
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 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
42 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
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
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
45
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 void EditProduct::refreshHops()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 QString w;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 QWidget* pWidget;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 QHBoxLayout* pLayout;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 qDebug() << "refreshHops" << product->hops.size();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 std::sort(product->hops.begin(), product->hops.end(), hop_sort_test);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 const QStringList labels({tr("Origin"), tr("Hop"), tr("Type"), tr("Form"), tr("Alpha"), tr("Use at"), tr("Time"),
178
1091fd9feffe Add hops inventory update during product load.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
57 tr("IBU"), 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
58
178
1091fd9feffe Add hops inventory update during product load.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
59 ui->hopsTable->setColumnCount(12);
191
7446ee2fb427 Added hops inventory check. Include all whirlpool steps in ibu calculations. Calculate the ibus in the fermenter including top up water. Use enum constants for the hops. Update the invenory state when replacing a hop.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
60 ui->hopsTable->setColumnWidth(0, 140); /* Origin */
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 ui->hopsTable->setColumnWidth(1, 225); /* Hop */
178
1091fd9feffe Add hops inventory update during product load.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
62 ui->hopsTable->setColumnWidth(2, 74); /* Type */
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 ui->hopsTable->setColumnWidth(3, 84); /* Form */
178
1091fd9feffe Add hops inventory update during product load.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
64 ui->hopsTable->setColumnWidth(4, 55); /* Alpha% */
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 ui->hopsTable->setColumnWidth(5, 75); /* Added */
178
1091fd9feffe Add hops inventory update during product load.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
66 ui->hopsTable->setColumnWidth(6, 65); /* Time */
1091fd9feffe Add hops inventory update during product load.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
67 ui->hopsTable->setColumnWidth(7, 50); /* IBU */
1091fd9feffe Add hops inventory update during product load.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
68 ui->hopsTable->setColumnWidth(8, 80); /* Amount */
1091fd9feffe Add hops inventory update during product load.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
69 ui->hopsTable->setColumnWidth(9, 80); /* Stock */
1091fd9feffe Add hops inventory update during product load.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
70 ui->hopsTable->setColumnWidth(10, 80); /* Delete */
1091fd9feffe Add hops inventory update during product load.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
71 ui->hopsTable->setColumnWidth(11, 80); /* Edit */
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 ui->hopsTable->setHorizontalHeaderLabels(labels);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 ui->hopsTable->verticalHeader()->hide();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 ui->hopsTable->setRowCount(product->hops.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->hops.size(); i++) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
78 ui->hopsTable->setItem(i, 0, new QTableWidgetItem(product->hops.at(i).origin));
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
79 ui->hopsTable->setItem(i, 1, new QTableWidgetItem(product->hops.at(i).name));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
81 item = new QTableWidgetItem(QCoreApplication::translate("HopTypes", g_hop_types[product->hops.at(i).type]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 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
83 ui->hopsTable->setItem(i, 2, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
85 item = new QTableWidgetItem(QCoreApplication::translate("HopForm", g_hop_forms[product->hops.at(i).form]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 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
87 ui->hopsTable->setItem(i, 3, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
89 item = new QTableWidgetItem(QString("%1%").arg(product->hops.at(i).alpha, 2, 'f', 1, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 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
91 ui->hopsTable->setItem(i, 4, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
93 item = new QTableWidgetItem(QCoreApplication::translate("HopUse", g_hop_useat[product->hops.at(i).useat]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 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
95 ui->hopsTable->setItem(i, 5, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
97 if (product->hops.at(i).useat == 2 || product->hops.at(i).useat == 4) { // Boil or whirlpool
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
98 item = new QTableWidgetItem(QString("%1 min.").arg(product->hops.at(i).time, 1, 'f', 0, '0'));
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
99 } else if (product->hops.at(i).useat == 5) { // Dry-hop
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
100 item = new QTableWidgetItem(QString("%1 days.").arg(product->hops.at(i).time / 1440, 1, 'f', 0, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 item = new QTableWidgetItem(QString(""));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 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
105 ui->hopsTable->setItem(i, 6, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
107 double ibu = Utils::toIBU(product->hops.at(i).useat, product->hops.at(i).form, product->preboil_sg, product->est_og3, product->batch_size,
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
108 product->hops.at(i).amount, product->hops.at(i).time, product->hops.at(i).alpha, product->ibu_method,
340
b9af88bfe972 Added cooling parameters to the toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
109 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time,
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
110 product->brew_cooling_method, 0, 0, product->hops.at(i).utilisation, product->hops.at(i).bu_factor);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0'));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 ui->hopsTable->setItem(i, 7, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
115 if (product->hops.at(i).amount < 1.0) {
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
116 item = new QTableWidgetItem(QString("%1 gr").arg(product->hops.at(i).amount * 1000.0, 2, 'f', 1, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 } else {
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
118 item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(i).amount, 4, 'f', 3, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 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
121 ui->hopsTable->setItem(i, 8, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122
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
123 if (block_hop(product->stage, product->hops.at(i).useat)) {
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
124 item = 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
125 } 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
126 if (product->hops.at(i).inventory < 1.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
127 item = new QTableWidgetItem(QString("%1 gr").arg(product->hops.at(i).inventory * 1000.0, 2, 'f', 1, '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
128 } 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
129 item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(i).inventory, 4, 'f', 3, '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
130 }
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->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
132 if (product->hops.at(i).inventory < product->hops.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
133 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
134 }
178
1091fd9feffe Add hops inventory update during product load.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
135 ui->hopsTable->setItem(i, 9, item);
1091fd9feffe Add hops inventory update during product load.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
136
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 /* Add the Delete row 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
138 if (block_hop(product->stage, product->hops.at(i).useat)) {
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 = 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
140 item->setToolTip(tr("Hop 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
141 ui->hopsTable->setItem(i, 10, item);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
142 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
143 item->setToolTip(tr("Hop 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
144 ui->hopsTable->setItem(i, 11, item);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
145 } 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
146 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
147 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
148 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
149 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
150 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteHopRow_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
151 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
152 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
153 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
154 pWidget->setLayout(pLayout);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
155 ui->hopsTable->setCellWidget(i, 10, pWidget);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156
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
157 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
158 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
159 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
160 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
161 connect(btn_edit, SIGNAL(clicked()), this, SLOT(editHopRow_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
162 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
163 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
164 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
165 pWidget->setLayout(pLayout);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
166 ui->hopsTable->setCellWidget(i, 11, 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
167 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
172 void EditProduct::hop_Flavour_valueChanged(int value)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 if (value < 20) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175 ui->hop_tasteShow->setStyleSheet(bar_20);
230
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
176 ui->hop_tasteShow->setFormat(tr("Very low"));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177 } else {
230
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
178 double s1 = 20.0 / value;
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
179 if (value < 40) {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
180 ui->hop_tasteShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
181 "stop: 0 #004D00, stop: %1 #004D00, stop: %2 #008C00, stop: 1 #008C00);}").arg(s1).arg(s1));
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
182 ui->hop_tasteShow->setFormat(tr("Low"));
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
183 } else {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
184 double s2 = 40.0 / value;
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
185 if (value < 60) {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
186 ui->hop_tasteShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
187 "stop: 0 #004D00, stop: %1 #004D00, stop: %2 #006C00, stop: %3 #006C00, stop: %4 #008C00, stop: 1 #008C00"
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
188 ");}").arg(s1).arg(s1).arg(s2).arg(s2));
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
189 ui->hop_tasteShow->setFormat(tr("Moderate"));
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
190 } else {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
191 double s3 = 60.0 / value;
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
192 if (value < 80) {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
193 ui->hop_tasteShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
194 "stop: 0 #004D00, stop: %1 #004D00, stop: %2 #006C00, stop: %3 #006C00, stop: %4 #008C00, stop: %5 #008C00, "
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
195 "stop: %6 #00AC00, stop: 1 #00AC00"
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
196 ");}").arg(s1).arg(s1).arg(s2).arg(s2).arg(s3).arg(s3));
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
197 ui->hop_tasteShow->setFormat(tr("High"));
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
198 } else {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
199 double s4 = 80.0 / value;
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
200 ui->hop_tasteShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
201 "stop: 0 #004D00, stop: %1 #004D00, stop: %2 #006C00, stop: %3 #006C00, stop: %4 #008C00, stop: %5 #008C00, "
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
202 "stop: %6 #00AC00, stop: %7 #00AC00, stop: %8 #00CC00, stop: 1 #00CC00"
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
203 ");}").arg(s1).arg(s1).arg(s2).arg(s2).arg(s3).arg(s3).arg(s4).arg(s4));
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
204 ui->hop_tasteShow->setFormat(tr("Very high"));
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
205 }
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
206 }
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
207 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
208 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 }
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
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 void EditProduct::hop_Aroma_valueChanged(int value)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 if (value < 20) {
230
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
215 ui->hop_aromaShow->setStyleSheet(bar_20);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 ui->hop_aromaShow->setFormat(tr("Very low"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 } else {
230
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
218 double s1 = 20.0 / value;
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
219 if (value < 40) {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
220 ui->hop_aromaShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
221 "stop: 0 #004D00, stop: %1 #004D00, stop: %2 #008C00, stop: 1 #008C00);}").arg(s1).arg(s1));
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
222 ui->hop_aromaShow->setFormat(tr("Low"));
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
223 } else {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
224 double s2 = 40.0 / value;
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
225 if (value < 60) {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
226 ui->hop_aromaShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
227 "stop: 0 #004D00, stop: %1 #004D00, stop: %2 #006C00, stop: %3 #006C00, stop: %4 #008C00, stop: 1 #008C00"
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
228 ");}").arg(s1).arg(s1).arg(s2).arg(s2));
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
229 ui->hop_aromaShow->setFormat(tr("Moderate"));
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
230 } else {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
231 double s3 = 60.0 / value;
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
232 if (value < 80) {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
233 ui->hop_aromaShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
234 "stop: 0 #004D00, stop: %1 #004D00, stop: %2 #006C00, stop: %3 #006C00, stop: %4 #008C00, stop: %5 #008C00, "
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
235 "stop: %6 #00AC00, stop: 1 #00AC00"
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
236 ");}").arg(s1).arg(s1).arg(s2).arg(s2).arg(s3).arg(s3));
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
237 ui->hop_aromaShow->setFormat(tr("High"));
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
238 } else {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
239 double s4 = 80.0 / value;
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
240 ui->hop_aromaShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
241 "stop: 0 #004D00, stop: %1 #004D00, stop: %2 #006C00, stop: %3 #006C00, stop: %4 #008C00, stop: %5 #008C00, "
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
242 "stop: %6 #00AC00, stop: %7 #00AC00, stop: %8 #00CC00, stop: 1 #00CC00"
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
243 ");}").arg(s1).arg(s1).arg(s2).arg(s2).arg(s3).arg(s3).arg(s4).arg(s4));
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
244 ui->hop_aromaShow->setFormat(tr("Very high"));
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
245 }
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
246 }
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 215
diff changeset
247 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
248 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
249 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
250
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
251
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
252 void EditProduct::calcIBUs()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
253 {
191
7446ee2fb427 Added hops inventory check. Include all whirlpool steps in ibu calculations. Calculate the ibus in the fermenter including top up water. Use enum constants for the hops. Update the invenory state when replacing a hop.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
254 double hop_flavour = 0, hop_aroma = 0, ibus = 0, ferm_ibus = 0;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
255
191
7446ee2fb427 Added hops inventory check. Include all whirlpool steps in ibu calculations. Calculate the ibus in the fermenter including top up water. Use enum constants for the hops. Update the invenory state when replacing a hop.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
256 product->hops_ok = true;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
257 for (int i = 0; i < product->hops.size(); i++) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
258
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
259 ibus += Utils::toIBU(product->hops.at(i).useat, product->hops.at(i).form, product->preboil_sg, product->est_og3,
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
260 product->batch_size, product->hops.at(i).amount,
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
261 product->hops.at(i).time, product->hops.at(i).alpha, product->ibu_method,
340
b9af88bfe972 Added cooling parameters to the toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
262 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time,
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
263 product->brew_cooling_method, 0, 0, product->hops.at(i).utilisation, product->hops.at(i).bu_factor);
398
49cf387e9070 After brewing show final IBU on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
264 if (product->stage > PROD_STAGE_BREW)
49cf387e9070 After brewing show final IBU on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
265 ferm_ibus += Utils::toIBU(product->hops.at(i).useat, product->hops.at(i).form, product->brew_preboil_sg, product->brew_fermenter_sg,
49cf387e9070 After brewing show final IBU on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
266 product->brew_fermenter_volume + product->brew_fermenter_tcloss, product->hops.at(i).amount,
49cf387e9070 After brewing show final IBU on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
267 product->hops.at(i).time, product->hops.at(i).alpha, product->ibu_method,
49cf387e9070 After brewing show final IBU on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
268 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time,
49cf387e9070 After brewing show final IBU on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
269 product->brew_cooling_method, 0, 0, product->hops.at(i).utilisation, product->hops.at(i).bu_factor);
49cf387e9070 After brewing show final IBU on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
270 else
49cf387e9070 After brewing show final IBU on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
271 ferm_ibus += Utils::toIBU(product->hops.at(i).useat, product->hops.at(i).form, product->preboil_sg, product->est_og3,
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
272 product->brew_fermenter_volume + product->brew_fermenter_tcloss, product->hops.at(i).amount,
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
273 product->hops.at(i).time, product->hops.at(i).alpha, product->ibu_method,
340
b9af88bfe972 Added cooling parameters to the toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
274 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time,
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
275 product->brew_cooling_method, 0, 0, product->hops.at(i).utilisation, product->hops.at(i).bu_factor);
191
7446ee2fb427 Added hops inventory check. Include all whirlpool steps in ibu calculations. Calculate the ibus in the fermenter including top up water. Use enum constants for the hops. Update the invenory state when replacing a hop.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
276
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
277 hop_flavour += Utils::hopFlavourContribution(product->hops.at(i).time, product->batch_size, product->hops.at(i).useat,
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
278 product->hops.at(i).amount, product->hops.at(i).form);
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
279 hop_aroma += Utils::hopAromaContribution(product->hops.at(i).time, product->batch_size, product->hops.at(i).useat,
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
280 product->hops.at(i).amount, product->hops.at(i).form);
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
281 if ((((product->inventory_reduced <= PROD_STAGE_BREW) && (product->hops.at(i).useat <= HOP_USEAT_WHIRLPOOL)) ||
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
282 ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->hops.at(i).useat == HOP_USEAT_DRY_HOP))) &&
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
283 (product->hops.at(i).inventory < product->hops.at(i).amount))
191
7446ee2fb427 Added hops inventory check. Include all whirlpool steps in ibu calculations. Calculate the ibus in the fermenter including top up water. Use enum constants for the hops. Update the invenory state when replacing a hop.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
284 product->hops_ok = false;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
285 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
286
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
287 hop_flavour = round(hop_flavour * 1000.0 / 5.0) / 10;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
288 hop_aroma = round(hop_aroma * 1000.0 / 6.0) / 10;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
289 if (hop_flavour > 100)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
290 hop_flavour = 100;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
291 if (hop_aroma > 100)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
292 hop_aroma = 100;
191
7446ee2fb427 Added hops inventory check. Include all whirlpool steps in ibu calculations. Calculate the ibus in the fermenter including top up water. Use enum constants for the hops. Update the invenory state when replacing a hop.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
293 qDebug() << "ibu" << product->est_ibu << ibus << "flavour" << hop_flavour << "aroma" << hop_aroma << "method" << product->ibu_method
7446ee2fb427 Added hops inventory check. Include all whirlpool steps in ibu calculations. Calculate the ibus in the fermenter including top up water. Use enum constants for the hops. Update the invenory state when replacing a hop.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
294 << "fermenter" << ferm_ibus << "supplies" << product->hops_ok;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
295
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
296 product->est_ibu = ibus;
191
7446ee2fb427 Added hops inventory check. Include all whirlpool steps in ibu calculations. Calculate the ibus in the fermenter including top up water. Use enum constants for the hops. Update the invenory state when replacing a hop.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
297 product->brew_fermenter_ibu = ferm_ibus;
398
49cf387e9070 After brewing show final IBU on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
298 if (product->stage > PROD_STAGE_BREW) {
399
4b9aaf86094e Prompts corrections and updated translations. Minor layout changes so the prompts will fit.
Michiel Broek <mbroek@mbse.eu>
parents: 398
diff changeset
299 ui->est_ibuLabel->setText(tr("Final IBU:"));
398
49cf387e9070 After brewing show final IBU on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
300 ui->est_ibuEdit->setValue(product->brew_fermenter_ibu);
49cf387e9070 After brewing show final IBU on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
301 ui->est_ibuShow->setValue(product->brew_fermenter_ibu);
49cf387e9070 After brewing show final IBU on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
302 } else {
49cf387e9070 After brewing show final IBU on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
303 ui->est_ibuEdit->setValue(product->est_ibu);
49cf387e9070 After brewing show final IBU on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
304 ui->est_ibuShow->setValue(product->est_ibu);
49cf387e9070 After brewing show final IBU on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 380
diff changeset
305 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
306 ui->est_ibu2Edit->setValue(product->est_ibu);
191
7446ee2fb427 Added hops inventory check. Include all whirlpool steps in ibu calculations. Calculate the ibus in the fermenter including top up water. Use enum constants for the hops. Update the invenory state when replacing a hop.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
307 ui->brew_fermentibuShow->setValue(product->brew_fermenter_ibu);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
308 ui->hop_tasteShow->setValue(hop_flavour);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
309 ui->hop_aromaShow->setValue(hop_aroma);
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
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
312
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
313 void EditProduct::addHopRow_clicked()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
314 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
315 Hops newh;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
316
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
317 qDebug() << "Add hop row";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
318
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
319 for (int i = 0; i < product->hops.size(); i++) {
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
320 if (product->hops.at(i).amount == 0 && product->hops.at(i).alpha == 0)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
321 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
322 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
323
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
324 newh.name = "Select one";
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
325 newh.origin = "";
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
326 newh.amount = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
327 newh.cost = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
328 newh.type = HOP_TYPE_BITTERING;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
329 newh.form = HOP_FORMS_PELLET;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
330 newh.useat = HOP_USEAT_BOIL;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
331 newh.time = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
332 newh.alpha = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
333 newh.beta = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
334 newh.hsi = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
335 newh.humulene = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
336 newh.caryophyllene = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
337 newh.cohumulone = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
338 newh.myrcene = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
339 newh.total_oil = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
340 newh.inventory = 0;
380
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
341 newh.utilisation = my_ut_pellet;
375
c21567bfd703 Final set the default utilisation to 20. Selecting another hop in a product now sets the new utilisation and bu_factor too. Removed experimental CO2 extract calculation and let it handle by the Tinseth formula. The Tinseth formula uses the Utilisation value in the final calculation. Moved the ISO extract formula for extract at bottling to the main toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
342 newh.bu_factor = 1;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
343
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
344 product->hops.append(newh);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
345 emit refreshAll();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
346 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
347
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
348
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
349 void EditProduct::deleteHopRow_clicked()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
350 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
351 if (product->locked || product->hops.size() < 1)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
352 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
353
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
354 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
355 int row = pb->objectName().toInt();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
356 qDebug() << "Delete hop row" << row << product->hops.size();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
357
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
358 int rc = QMessageBox::warning(this, tr("Delete hop"), tr("Delete %1").arg(product->hops.at(row).name),
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
359 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
360 if (rc == QMessageBox::No)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
361 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
362
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
363 product->hops.removeAt(row);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
364 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
365 emit refreshAll();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
366 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
367
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
368
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
369 void EditProduct::hop_amount_changed(double val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
370 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
371 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
372
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
373 qDebug() << "hop_amount_changed()" << product->hops_row << val;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
374
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
375 product->hops[product->hops_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
376 item = new QTableWidgetItem(QString("%1 gr").arg(val, 2, 'f', 1, '0'));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
377 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
378 ui->hopsTable->setItem(product->hops_row, 8, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
379
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
380 double ibu = Utils::toIBU(product->hops.at(product->hops_row).useat, product->hops.at(product->hops_row).form, product->preboil_sg, product->est_og3,
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
381 product->batch_size, product->hops.at(product->hops_row).amount, product->hops.at(product->hops_row).time,
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
382 product->hops.at(product->hops_row).alpha, product->ibu_method,
340
b9af88bfe972 Added cooling parameters to the toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
383 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time,
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
384 product->brew_cooling_method, 0, 0,
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
385 product->hops.at(product->hops_row).utilisation, product->hops.at(product->hops_row).bu_factor);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
386
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
387 ibuEdit->setValue(ibu);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
388 item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0'));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
389 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
390 ui->hopsTable->setItem(product->hops_row, 7, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
391
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
392 calcIBUs();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
393 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
394 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
395
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
396
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
397 void EditProduct::hop_time_changed(int val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
398 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
399 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
400
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
401 qDebug() << "hop_time_changed()" << product->hops_row << val;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
402
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
403 if (product->hops.at(product->hops_row).useat == HOP_USEAT_BOIL || product->hops.at(product->hops_row).useat == HOP_USEAT_WHIRLPOOL) {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
404 item = new QTableWidgetItem(QString("%1 min.").arg(val, 1, 'f', 0, '0'));
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
405 product->hops[product->hops_row].time = val;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
406 } else if (product->hops.at(product->hops_row).useat == HOP_USEAT_DRY_HOP) {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
407 item = new QTableWidgetItem(QString("%1 days.").arg(val, 1, 'f', 0, '0'));
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
408 product->hops[product->hops_row].time = val * 1440;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
409 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
410 item = new QTableWidgetItem(QString(""));
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
411 product->hops[product->hops_row].time = val;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
412 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
413 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
414 ui->hopsTable->setItem(product->hops_row, 6, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
415
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
416 double ibu = Utils::toIBU(product->hops.at(product->hops_row).useat, product->hops.at(product->hops_row).form, product->preboil_sg, product->est_og3,
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
417 product->batch_size, product->hops.at(product->hops_row).amount, product->hops.at(product->hops_row).time,
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
418 product->hops.at(product->hops_row).alpha, product->ibu_method,
340
b9af88bfe972 Added cooling parameters to the toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
419 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time,
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
420 product->brew_cooling_method, 0, 0,
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
421 product->hops.at(product->hops_row).utilisation, product->hops.at(product->hops_row).bu_factor);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
422
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
423 ibuEdit->setValue(ibu);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
424 item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0'));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
425 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
426 ui->hopsTable->setItem(product->hops_row, 7, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
427
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
428 calcIBUs();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
429 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
430 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
431
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
432
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
433 void EditProduct::hop_select_changed(int val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
434 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
435 QSqlQuery query;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
436 bool instock = hinstockEdit->isChecked();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
437 QString w;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
438 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
439
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
440 if (val < 1)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
441 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
442
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
443 qDebug() << "hop_select_changed()" << product->fermentables_row << val << instock;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
444
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
445 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
446 * Search the hop 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
447 */
375
c21567bfd703 Final set the default utilisation to 20. Selecting another hop in a product now sets the new utilisation and bu_factor too. Removed experimental CO2 extract calculation and let it handle by the Tinseth formula. The Tinseth formula uses the Utilisation value in the final calculation. Moved the ISO extract formula for extract at bottling to the main toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
448 QString sql = "SELECT * FROM inventory_hops ";
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
449 if (instock)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
450 sql.append("WHERE inventory > 0 ");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
451 sql.append("ORDER BY origin,name");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
452 query.prepare(sql);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
453 query.exec();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
454 query.first();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
455 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
456 query.next();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
457 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
458
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
459 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
460 * Replace the hop record contents
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
461 */
375
c21567bfd703 Final set the default utilisation to 20. Selecting another hop in a product now sets the new utilisation and bu_factor too. Removed experimental CO2 extract calculation and let it handle by the Tinseth formula. The Tinseth formula uses the Utilisation value in the final calculation. Moved the ISO extract formula for extract at bottling to the main toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
462 product->hops[product->hops_row].name = query.value("name").toString();
c21567bfd703 Final set the default utilisation to 20. Selecting another hop in a product now sets the new utilisation and bu_factor too. Removed experimental CO2 extract calculation and let it handle by the Tinseth formula. The Tinseth formula uses the Utilisation value in the final calculation. Moved the ISO extract formula for extract at bottling to the main toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
463 product->hops[product->hops_row].origin = query.value("origin").toString();
c21567bfd703 Final set the default utilisation to 20. Selecting another hop in a product now sets the new utilisation and bu_factor too. Removed experimental CO2 extract calculation and let it handle by the Tinseth formula. The Tinseth formula uses the Utilisation value in the final calculation. Moved the ISO extract formula for extract at bottling to the main toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
464 product->hops[product->hops_row].alpha = query.value("alpha").toDouble();
c21567bfd703 Final set the default utilisation to 20. Selecting another hop in a product now sets the new utilisation and bu_factor too. Removed experimental CO2 extract calculation and let it handle by the Tinseth formula. The Tinseth formula uses the Utilisation value in the final calculation. Moved the ISO extract formula for extract at bottling to the main toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
465 product->hops[product->hops_row].beta = query.value("beta").toDouble();
c21567bfd703 Final set the default utilisation to 20. Selecting another hop in a product now sets the new utilisation and bu_factor too. Removed experimental CO2 extract calculation and let it handle by the Tinseth formula. The Tinseth formula uses the Utilisation value in the final calculation. Moved the ISO extract formula for extract at bottling to the main toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
466 product->hops[product->hops_row].humulene = query.value("humulene").toDouble();
c21567bfd703 Final set the default utilisation to 20. Selecting another hop in a product now sets the new utilisation and bu_factor too. Removed experimental CO2 extract calculation and let it handle by the Tinseth formula. The Tinseth formula uses the Utilisation value in the final calculation. Moved the ISO extract formula for extract at bottling to the main toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
467 product->hops[product->hops_row].caryophyllene = query.value("caryophyllene").toDouble();
c21567bfd703 Final set the default utilisation to 20. Selecting another hop in a product now sets the new utilisation and bu_factor too. Removed experimental CO2 extract calculation and let it handle by the Tinseth formula. The Tinseth formula uses the Utilisation value in the final calculation. Moved the ISO extract formula for extract at bottling to the main toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
468 product->hops[product->hops_row].cohumulone = query.value("cohumulone").toDouble();
c21567bfd703 Final set the default utilisation to 20. Selecting another hop in a product now sets the new utilisation and bu_factor too. Removed experimental CO2 extract calculation and let it handle by the Tinseth formula. The Tinseth formula uses the Utilisation value in the final calculation. Moved the ISO extract formula for extract at bottling to the main toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
469 product->hops[product->hops_row].myrcene = query.value("myrcene").toDouble();
c21567bfd703 Final set the default utilisation to 20. Selecting another hop in a product now sets the new utilisation and bu_factor too. Removed experimental CO2 extract calculation and let it handle by the Tinseth formula. The Tinseth formula uses the Utilisation value in the final calculation. Moved the ISO extract formula for extract at bottling to the main toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
470 product->hops[product->hops_row].hsi = query.value("hsi").toDouble();
c21567bfd703 Final set the default utilisation to 20. Selecting another hop in a product now sets the new utilisation and bu_factor too. Removed experimental CO2 extract calculation and let it handle by the Tinseth formula. The Tinseth formula uses the Utilisation value in the final calculation. Moved the ISO extract formula for extract at bottling to the main toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
471 product->hops[product->hops_row].total_oil = query.value("total_oil").toDouble();
c21567bfd703 Final set the default utilisation to 20. Selecting another hop in a product now sets the new utilisation and bu_factor too. Removed experimental CO2 extract calculation and let it handle by the Tinseth formula. The Tinseth formula uses the Utilisation value in the final calculation. Moved the ISO extract formula for extract at bottling to the main toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
472 product->hops[product->hops_row].type = query.value("type").toInt();
c21567bfd703 Final set the default utilisation to 20. Selecting another hop in a product now sets the new utilisation and bu_factor too. Removed experimental CO2 extract calculation and let it handle by the Tinseth formula. The Tinseth formula uses the Utilisation value in the final calculation. Moved the ISO extract formula for extract at bottling to the main toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
473 product->hops[product->hops_row].form = query.value("form").toInt();
c21567bfd703 Final set the default utilisation to 20. Selecting another hop in a product now sets the new utilisation and bu_factor too. Removed experimental CO2 extract calculation and let it handle by the Tinseth formula. The Tinseth formula uses the Utilisation value in the final calculation. Moved the ISO extract formula for extract at bottling to the main toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
474 product->hops[product->hops_row].cost = query.value("cost").toDouble();
c21567bfd703 Final set the default utilisation to 20. Selecting another hop in a product now sets the new utilisation and bu_factor too. Removed experimental CO2 extract calculation and let it handle by the Tinseth formula. The Tinseth formula uses the Utilisation value in the final calculation. Moved the ISO extract formula for extract at bottling to the main toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
475 product->hops[product->hops_row].inventory = query.value("inventory").toDouble();
c21567bfd703 Final set the default utilisation to 20. Selecting another hop in a product now sets the new utilisation and bu_factor too. Removed experimental CO2 extract calculation and let it handle by the Tinseth formula. The Tinseth formula uses the Utilisation value in the final calculation. Moved the ISO extract formula for extract at bottling to the main toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
476 product->hops[product->hops_row].utilisation = query.value("utilisation").toDouble();
c21567bfd703 Final set the default utilisation to 20. Selecting another hop in a product now sets the new utilisation and bu_factor too. Removed experimental CO2 extract calculation and let it handle by the Tinseth formula. The Tinseth formula uses the Utilisation value in the final calculation. Moved the ISO extract formula for extract at bottling to the main toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
477 product->hops[product->hops_row].bu_factor = query.value("bu_factor").toDouble();
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
478
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
479 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
480 * Update the visible fields
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
481 */
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
482 hnameEdit->setText(product->hops.at(product->hops_row).name);
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
483 horiginEdit->setText(product->hops.at(product->hops_row).origin);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
484
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
485 double ibu = Utils::toIBU(product->hops.at(product->hops_row).useat, product->hops.at(product->hops_row).form, product->preboil_sg, product->est_og3,
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
486 product->batch_size, product->hops.at(product->hops_row).amount, product->hops.at(product->hops_row).time,
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
487 product->hops.at(product->hops_row).alpha, product->ibu_method,
340
b9af88bfe972 Added cooling parameters to the toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
488 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time,
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
489 product->brew_cooling_method, 0, 0,
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
490 product->hops.at(product->hops_row).utilisation, product->hops.at(product->hops_row).bu_factor);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
491 ibuEdit->setValue(ibu);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
492
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
493 ui->hopsTable->setItem(product->hops_row, 0, new QTableWidgetItem(product->hops.at(product->hops_row).origin));
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
494 ui->hopsTable->setItem(product->hops_row, 1, new QTableWidgetItem(product->hops.at(product->hops_row).name));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
495
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
496 QString hoptype = QCoreApplication::translate("HopTypes", g_hop_types[product->hops.at(product->hops_row).type]);
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
497 item = new QTableWidgetItem(hoptype);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
498 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
499 ui->hopsTable->setItem(product->hops_row, 2, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
500
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
501
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
502 item = new QTableWidgetItem(QCoreApplication::translate("HopForm", g_hop_forms[product->hops.at(product->hops_row).form]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
503 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
504 ui->hopsTable->setItem(product->hops_row, 3, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
505
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
506 item = new QTableWidgetItem(QString("%1%").arg(product->hops.at(product->hops_row).alpha, 2, 'f', 1, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
507 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
508 ui->hopsTable->setItem(product->hops_row, 4, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
509
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
510 item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0'));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
511 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
512 ui->hopsTable->setItem(product->hops_row, 7, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
513
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
514 if (product->hops.at(product->hops_row).inventory < 1.0) {
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
515 item = new QTableWidgetItem(QString("%1 gr").arg(product->hops.at(product->hops_row).inventory * 1000.0, 2, 'f', 1, '0'));
191
7446ee2fb427 Added hops inventory check. Include all whirlpool steps in ibu calculations. Calculate the ibus in the fermenter including top up water. Use enum constants for the hops. Update the invenory state when replacing a hop.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
516 } else {
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
517 item = new QTableWidgetItem(QString("%1 kg").arg(product->hops.at(product->hops_row).inventory, 4, 'f', 3, '0'));
191
7446ee2fb427 Added hops inventory check. Include all whirlpool steps in ibu calculations. Calculate the ibus in the fermenter including top up water. Use enum constants for the hops. Update the invenory state when replacing a hop.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
518 }
7446ee2fb427 Added hops inventory check. Include all whirlpool steps in ibu calculations. Calculate the ibus in the fermenter including top up water. Use enum constants for the hops. Update the invenory state when replacing a hop.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
519 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
520 if (product->hops.at(product->hops_row).inventory < product->hops.at(product->hops_row).amount)
191
7446ee2fb427 Added hops inventory check. Include all whirlpool steps in ibu calculations. Calculate the ibus in the fermenter including top up water. Use enum constants for the hops. Update the invenory state when replacing a hop.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
521 item->setForeground(QBrush(QColor(Qt::red)));
7446ee2fb427 Added hops inventory check. Include all whirlpool steps in ibu calculations. Calculate the ibus in the fermenter including top up water. Use enum constants for the hops. Update the invenory state when replacing a hop.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
522 ui->hopsTable->setItem(product->hops_row, 9, item);
7446ee2fb427 Added hops inventory check. Include all whirlpool steps in ibu calculations. Calculate the ibus in the fermenter including top up water. Use enum constants for the hops. Update the invenory state when replacing a hop.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
523
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
524 calcIBUs();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
525 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
526 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
527
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
528
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
529 void EditProduct::hop_instock_changed(bool val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
530 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
531 QSqlQuery query;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
532
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
533 qDebug() << "hop_instock_changed()" << product->hops_row << val;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
534
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
535 this->hselectEdit->setCurrentIndex(-1);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
536 this->hselectEdit->clear();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
537 QString sql = "SELECT origin,name,alpha,inventory FROM inventory_hops ";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
538 if (val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
539 sql.append("WHERE inventory > 0 ");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
540 sql.append("ORDER BY origin,name");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
541 query.prepare(sql);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
542 query.exec();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
543 query.first();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
544 this->hselectEdit->addItem(""); // Start with empty value
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
545 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
546 this->hselectEdit->addItem(query.value(0).toString()+" - "+query.value(1).toString()+" ("+query.value(2).toString()+"%) "+
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
547 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
548 query.next();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
549 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
550 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
551
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
552
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
553 void EditProduct::hop_useat_changed(int val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
554 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
555 qDebug() << "hop_useat_changed()" << product->hops_row << val;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
556
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
557 product->hops[product->hops_row].useat = val;
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
558 QTableWidgetItem *item = new QTableWidgetItem(QCoreApplication::translate("HopUse", g_hop_useat[val]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
559 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
560 ui->hopsTable->setItem(product->hops_row, 5, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
561
191
7446ee2fb427 Added hops inventory check. Include all whirlpool steps in ibu calculations. Calculate the ibus in the fermenter including top up water. Use enum constants for the hops. Update the invenory state when replacing a hop.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
562 if (val == HOP_USEAT_BOIL || val == HOP_USEAT_WHIRLPOOL) {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
563 htimeLabel->setText(tr("Time in minutes:"));
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
564 htimeEdit->setValue(product->hops.at(product->hops_row).time);
380
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
565 htimeLabel->show();
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
566 htimeEdit->show();
191
7446ee2fb427 Added hops inventory check. Include all whirlpool steps in ibu calculations. Calculate the ibus in the fermenter including top up water. Use enum constants for the hops. Update the invenory state when replacing a hop.
Michiel Broek <mbroek@mbse.eu>
parents: 178
diff changeset
567 } else if (val == HOP_USEAT_DRY_HOP) {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
568 htimeLabel->setText(tr("Time in days:"));
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
569 htimeEdit->setValue(product->hops.at(product->hops_row).time / 1440);
380
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
570 htimeLabel->show();
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
571 htimeEdit->show();
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
572 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
573 htimeEdit->setValue(0);
380
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
574 htimeLabel->hide();
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
575 htimeEdit->hide();
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
576 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
577
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
578 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
579 emit refreshAll();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
580 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
581
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
582
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
583 void EditProduct::editHopRow_clicked()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
584 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
585 QSqlQuery query;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
586
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
587 if (product->locked)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
588 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
589
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
590 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
591 product->hops_row = pb->objectName().toInt();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
592 qDebug() << "Edit hop row" << product->hops_row;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
593 Hops backup = product->hops.at(product->hops_row);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
594
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
595 QDialog* dialog = new QDialog(this);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
596 dialog->resize(738, 260);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
597 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
598 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
599 buttonBox->setGeometry(QRect(30, 210, 671, 32));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
600 buttonBox->setLayoutDirection(Qt::LeftToRight);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
601 buttonBox->setOrientation(Qt::Horizontal);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
602 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
603 buttonBox->setCenterButtons(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
604 QLabel *nameLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
605 nameLabel->setObjectName(QString::fromUtf8("nameLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
606 nameLabel->setText(tr("Current hop:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
607 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
608 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
609 QLabel *originLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
610 originLabel->setObjectName(QString::fromUtf8("originLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
611 originLabel->setText(tr("Origin:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
612 originLabel->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
613 originLabel->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
614 QLabel *amountLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
615 amountLabel->setObjectName(QString::fromUtf8("amountLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
616 amountLabel->setText(tr("Amount in gr:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
617 amountLabel->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
618 amountLabel->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
619 htimeLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
620 htimeLabel->setObjectName(QString::fromUtf8("htimeLabel"));
380
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
621 if (product->hops.at(product->hops_row).useat == HOP_USEAT_DRY_HOP)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
622 htimeLabel->setText(tr("Time in days:"));
380
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
623 else
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
624 htimeLabel->setText(tr("Time in minutes:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
625
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
626 htimeLabel->setGeometry(QRect(10, 130, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
627 htimeLabel->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
628 QLabel *useatLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
629 useatLabel->setObjectName(QString::fromUtf8("useatLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
630 useatLabel->setText(tr("Use at:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
631 useatLabel->setGeometry(QRect(10, 160, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
632 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
633 QLabel *selectLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
634 selectLabel->setObjectName(QString::fromUtf8("selectLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
635 selectLabel->setText(tr("Select hop:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
636 selectLabel->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
637 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
638 QLabel *instockLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
639 instockLabel->setObjectName(QString::fromUtf8("instockLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
640 instockLabel->setText(tr("In stock:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
641 instockLabel->setGeometry(QRect(525, 70, 121, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
642 instockLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
643 QLabel *ibuLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
644 ibuLabel->setObjectName(QString::fromUtf8("maxLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
645 ibuLabel->setText(tr("Bitterness IBU:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
646 ibuLabel->setGeometry(QRect(420, 130, 121, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
647 ibuLabel->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
648
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
649 hselectEdit = new QComboBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
650 hselectEdit->setObjectName(QString::fromUtf8("selectEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
651 hselectEdit->setGeometry(QRect(160, 70, 371, 23));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
652
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
653 hnameEdit = new QLineEdit(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
654 hnameEdit->setObjectName(QString::fromUtf8("hnameEdit"));
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
655 hnameEdit->setText(product->hops.at(product->hops_row).name);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
656 hnameEdit->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
657 hnameEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
658 horiginEdit = new QLineEdit(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
659 horiginEdit->setObjectName(QString::fromUtf8("horiginEdit"));
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
660 horiginEdit->setText(product->hops.at(product->hops_row).origin);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
661 horiginEdit->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
662 horiginEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
663 hamountEdit = new QDoubleSpinBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
664 hamountEdit->setObjectName(QString::fromUtf8("hamountEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
665 hamountEdit->setGeometry(QRect(160, 100, 121, 24));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
666 hamountEdit->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
667 hamountEdit->setAccelerated(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
668 hamountEdit->setDecimals(1);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
669 hamountEdit->setMaximum(1000000.0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
670 hamountEdit->setSingleStep(0.5);
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
671 hamountEdit->setValue(product->hops.at(product->hops_row).amount * 1000.0);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
672 htimeEdit = new QSpinBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
673 htimeEdit->setObjectName(QString::fromUtf8("htimeEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
674 htimeEdit->setGeometry(QRect(160, 130, 121, 24));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
675 htimeEdit->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
676 htimeEdit->setAccelerated(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
677 htimeEdit->setMaximum(10000.0);
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
678 if (product->hops.at(product->hops_row).useat == HOP_USEAT_BOIL || product->hops.at(product->hops_row).useat == HOP_USEAT_WHIRLPOOL) {
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
679 htimeEdit->setValue(product->hops.at(product->hops_row).time);
380
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
680 htimeLabel->show();
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
681 htimeEdit->show();
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
682 } else if (product->hops.at(product->hops_row).useat == HOP_USEAT_DRY_HOP) {
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
683 htimeEdit->setValue(product->hops.at(product->hops_row).time / 1440);
380
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
684 htimeLabel->show();
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
685 htimeEdit->show();
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
686 } else {
380
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
687 htimeLabel->hide();
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
688 htimeEdit->hide();
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
689 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
690 useatEdit = new QComboBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
691 useatEdit->setObjectName(QString::fromUtf8("useatEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
692 useatEdit->setGeometry(QRect(160, 160, 161, 23));
380
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
693 for (int i = 0; i < 7; i++)
8f5c03ed4321 Global setup added hop utilisation defaults, these are used by the hops editor. In the hops editor, changing the hop form sets the new default utilisation. Hide and show the time edit entry instead of setting it read-only. The new defaults are loaded at program startup. Changed the global setup for the new utilisation fields and dropped the obsolete factor fields. The toIBU formula doesn't use my_factor_* variables anymore, hop differences now come from the utilisation field per hop. The global database is updated to the new defaults.
Michiel Broek <mbroek@mbse.eu>
parents: 375
diff changeset
694 useatEdit->addItem(QCoreApplication::translate("HopUse", g_hop_useat[i]));
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
695 useatEdit->setCurrentIndex(product->hops.at(product->hops_row).useat);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
696
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
697 hinstockEdit = new QCheckBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
698 hinstockEdit->setObjectName(QString::fromUtf8("hinstockEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
699 hinstockEdit->setGeometry(QRect(655, 70, 85, 21));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
700 hinstockEdit->setChecked(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
701
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
702 ibuEdit = new QDoubleSpinBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
703 ibuEdit->setObjectName(QString::fromUtf8("ibuEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
704 ibuEdit->setGeometry(QRect(550, 130, 121, 24));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
705 ibuEdit->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
706 ibuEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
707 ibuEdit->setButtonSymbols(QAbstractSpinBox::NoButtons);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
708 ibuEdit->setDecimals(1);
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
709 double ibu = Utils::toIBU(product->hops.at(product->hops_row).useat, product->hops.at(product->hops_row).form, product->preboil_sg, product->est_og3,
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
710 product->batch_size, product->hops.at(product->hops_row).amount, product->hops.at(product->hops_row).time,
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
711 product->hops.at(product->hops_row).alpha, product->ibu_method,
340
b9af88bfe972 Added cooling parameters to the toIBU function.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
712 product->brew_whirlpool9, product->brew_whirlpool7, product->brew_whirlpool6, product->boil_time,
373
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
713 product->brew_cooling_method, 0, 0,
b02aca4e926c First load of changes for hops. In EditHop load the dropdown buttons from the global table. Use named query fields. Added database utilisation and bu_factor fields for hop extracts. Added edit fields for these new fields. Added post boil SG, utilisation and bu_factor parameters to the toIBU function. Added hops form parameter to the hopFlavourContribution and hopAromaContribution display bars. In the hops inventory list dispay volumes instead of weight for hop extracts. Modified the TinsethIBU function to use utilisation and bu_factor parameters. Add calculations for co2 and iso hop extracts, this is work in progress. The toIBU function makes use of the preSG and postSG values to use the correct SG to caall the TinsethIBU function. This results in a bit lower IBU values mostly affecting the late additions. Added use hop at bottling for iso hop extracts like Tetra hops using the formula from BarthHaas.
Michiel Broek <mbroek@mbse.eu>
parents: 340
diff changeset
714 product->hops.at(product->hops_row).utilisation, product->hops.at(product->hops_row).bu_factor);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
715 ibuEdit->setValue(ibu);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
716
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
717 hop_instock_changed(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
718
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
719 connect(hselectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::hop_select_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
720 connect(hamountEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::hop_amount_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
721 connect(htimeEdit, QOverload<int>::of(&QSpinBox::valueChanged), this, &EditProduct::hop_time_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
722 connect(useatEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::hop_useat_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
723 connect(hinstockEdit, &QCheckBox::stateChanged, this, &EditProduct::hop_instock_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
724 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
725 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
726
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
727 dialog->setModal(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
728 dialog->exec();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
729 if (dialog->result() == QDialog::Rejected) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
730 qDebug() << "reject and rollback";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
731 product->hops[product->hops_row] = backup;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
732 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
733 /* Clear time if hop is not used for boil, whirlpool or dry-hop. */
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
734 if (! (product->hops.at(product->hops_row).useat == HOP_USEAT_BOIL ||
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
735 product->hops.at(product->hops_row).useat == HOP_USEAT_WHIRLPOOL ||
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
736 product->hops.at(product->hops_row).useat == HOP_USEAT_DRY_HOP)) {
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
737 if (product->hops.at(product->hops_row).time) {
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
738 product->hops[product->hops_row].time = 0;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
739 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
740 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
741 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
742 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
743
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
744 disconnect(hselectEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
745 disconnect(hamountEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
746 disconnect(htimeEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
747 disconnect(useatEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
748 disconnect(hinstockEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
749 disconnect(buttonBox, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
750
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
751 emit refreshAll();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
752 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
753
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
754
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
755 void EditProduct::adjustHops(double factor)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
756 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
757 double amount;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
758
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
759 if (product->hops.size() == 0)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
760 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
761
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
762 for (int i = 0; i < product->hops.size(); i++) {
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
763 amount = product->hops.at(i).amount * factor;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
764 product->hops[i].amount = amount;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
765 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
766 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
767
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
768

mercurial