src/EditRecipeTab3.cpp

Mon, 04 Mar 2024 19:51:57 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 04 Mar 2024 19:51:57 +0100
changeset 520
9166c0b82ada
parent 454
2dfead81c72f
permissions
-rw-r--r--

Code cleanup

127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * EditRecipe.cpp is part of bmsapp.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * Tab 3, hops
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * bmsapp is free software: you can redistribute it and/or modify
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * the Free Software Foundation, either version 3 of the License, or
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * (at your option) any later version.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 *
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * bmsapp is distributed in the hope that it will be useful,
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * GNU General Public License for more details.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 *
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 bool EditRecipe::hop_sort_test(const Hops &D1, const Hops &D2)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 {
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
24 if (D1.useat > D2.useat)
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 return false;
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
26 if (D1.useat < D2.useat)
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 return true;
475c8b8df67f Split recipes source in tabs.
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: 263
diff changeset
29 if (D1.time < D2.time)
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 return false;
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
31 if (D1.time > D2.time)
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 return true;
475c8b8df67f Split recipes source in tabs.
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: 263
diff changeset
34 return (D1.amount > D2.amount);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 void EditRecipe::refreshHops()
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 QString w;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 QWidget* pWidget;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 QHBoxLayout* pLayout;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
43 QTableWidgetItem *item;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
45 std::sort(recipe->hops.begin(), recipe->hops.end(), hop_sort_test);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 const QStringList labels({tr("Origin"), tr("Hop"), tr("Type"), tr("Form"), tr("Alpha"), tr("Use at"), tr("Time"),
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48 tr("IBU"), tr("Amount"), tr("Delete"), tr("Edit") });
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 ui->hopsTable->setColumnCount(11);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 ui->hopsTable->setColumnWidth(0, 150); /* Origin */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 ui->hopsTable->setColumnWidth(1, 225); /* Hop */
131
0115b97e8c39 Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.
Michiel Broek <mbroek@mbse.eu>
parents: 129
diff changeset
53 ui->hopsTable->setColumnWidth(2, 84); /* Type */
0115b97e8c39 Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.
Michiel Broek <mbroek@mbse.eu>
parents: 129
diff changeset
54 ui->hopsTable->setColumnWidth(3, 84); /* Form */
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 ui->hopsTable->setColumnWidth(4, 75); /* Alpha% */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 ui->hopsTable->setColumnWidth(5, 75); /* Added */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 ui->hopsTable->setColumnWidth(6, 75); /* Time */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 ui->hopsTable->setColumnWidth(7, 60); /* IBU */
131
0115b97e8c39 Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.
Michiel Broek <mbroek@mbse.eu>
parents: 129
diff changeset
59 ui->hopsTable->setColumnWidth(8, 90); /* Amount */
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 ui->hopsTable->setColumnWidth(9, 80); /* Delete */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 ui->hopsTable->setColumnWidth(10, 80); /* Edit */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 ui->hopsTable->setHorizontalHeaderLabels(labels);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 ui->hopsTable->verticalHeader()->hide();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 ui->hopsTable->setRowCount(recipe->hops.size());
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 for (int i = 0; i < recipe->hops.size(); i++) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
68 ui->hopsTable->setItem(i, 0, new QTableWidgetItem(recipe->hops.at(i).origin));
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
69 ui->hopsTable->setItem(i, 1, new QTableWidgetItem(recipe->hops.at(i).name));
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
71 item = new QTableWidgetItem(QCoreApplication::translate("HopTypes", g_hop_types[recipe->hops.at(i).type]));
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 ui->hopsTable->setItem(i, 2, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
75 item = new QTableWidgetItem(QCoreApplication::translate("HopForm", g_hop_forms[recipe->hops.at(i).form]));
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 ui->hopsTable->setItem(i, 3, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
79 item = new QTableWidgetItem(QString("%1%").arg(recipe->hops.at(i).alpha, 2, 'f', 1, '0'));
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 ui->hopsTable->setItem(i, 4, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
83 item = new QTableWidgetItem(QCoreApplication::translate("HopUse", g_hop_useat[recipe->hops.at(i).useat]));
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 ui->hopsTable->setItem(i, 5, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
87 if (recipe->hops.at(i).useat == 2 || recipe->hops.at(i).useat == 4) { // Boil or whirlpool
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
88 item = new QTableWidgetItem(QString("%1 min.").arg(recipe->hops.at(i).time, 1, 'f', 0, '0'));
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
89 } else if (recipe->hops.at(i).useat == 5) { // Dry-hop
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
90 item = new QTableWidgetItem(QString("%1 days.").arg(recipe->hops.at(i).time / 1440, 1, 'f', 0, '0'));
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 } else {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 item = new QTableWidgetItem(QString(""));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 ui->hopsTable->setItem(i, 6, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96
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
97 double ibu = Utils::toIBU(recipe->hops.at(i).useat, recipe->hops.at(i).form, recipe->preboil_sg, recipe->est_og,
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
98 recipe->batch_size, recipe->hops.at(i).amount,
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
99 recipe->hops.at(i).time, recipe->hops.at(i).alpha, recipe->ibu_method, 0, recipe->hops.at(i).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
100 0, recipe->boil_time, 0, 0, 0, recipe->hops.at(i).utilisation, recipe->hops.at(i).bu_factor);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0'));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 ui->hopsTable->setItem(i, 7, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
105 if (recipe->hops.at(i).amount < 1.0) {
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
106 item = new QTableWidgetItem(QString("%1 gr").arg(recipe->hops.at(i).amount * 1000.0, 2, 'f', 1, '0'));
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 } else {
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
108 item = new QTableWidgetItem(QString("%1 kg").arg(recipe->hops.at(i).amount, 4, 'f', 3, '0'));
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 ui->hopsTable->setItem(i, 8, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 /* Add the Delete row button */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 pWidget = new QWidget();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 QPushButton* btn_dele = new QPushButton();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 btn_dele->setText(tr("Delete"));
139
f947c6988e91 Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
118 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteHopRow_clicked()));
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119 pLayout = new QHBoxLayout(pWidget);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 pLayout->addWidget(btn_dele);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 pLayout->setContentsMargins(5, 0, 5, 0);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
122 pWidget->setLayout(pLayout);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123 ui->hopsTable->setCellWidget(i, 9, pWidget);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 pWidget = new QWidget();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 QPushButton* btn_edit = new QPushButton();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127 btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128 btn_edit->setText(tr("Edit"));
139
f947c6988e91 Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
129 connect(btn_edit, SIGNAL(clicked()), this, SLOT(editHopRow_clicked()));
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130 pLayout = new QHBoxLayout(pWidget);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
131 pLayout->addWidget(btn_edit);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
132 pLayout->setContentsMargins(5, 0, 5, 0);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 pWidget->setLayout(pLayout);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134 ui->hopsTable->setCellWidget(i, 10, pWidget);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138
139
f947c6988e91 Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
139 void EditRecipe::hop_Flavour_valueChanged(int value)
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
140 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141 if (value < 20) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 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: 208
diff changeset
143 ui->hop_tasteShow->setFormat(tr("Very low"));
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
144 } else {
230
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
145 double s1 = 20.0 / value;
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
146 if (value < 40) {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
147 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: 208
diff changeset
148 "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: 208
diff changeset
149 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: 208
diff changeset
150 } else {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
151 double s2 = 40.0 / value;
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
152 if (value < 60) {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
153 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: 208
diff changeset
154 "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: 208
diff changeset
155 ");}").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: 208
diff changeset
156 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: 208
diff changeset
157 } else {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
158 double s3 = 60.0 / value;
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
159 if (value < 80) {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
160 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: 208
diff changeset
161 "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: 208
diff changeset
162 "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: 208
diff changeset
163 ");}").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: 208
diff changeset
164 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: 208
diff changeset
165 } else {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
166 double s4 = 80.0 / value;
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
167 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: 208
diff changeset
168 "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: 208
diff changeset
169 "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: 208
diff changeset
170 ");}").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: 208
diff changeset
171 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: 208
diff changeset
172 }
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
173 }
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
174 }
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
176 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178
139
f947c6988e91 Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
179 void EditRecipe::hop_Aroma_valueChanged(int value)
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 if (value < 20) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 ui->hop_aromaShow->setStyleSheet(bar_20);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 ui->hop_aromaShow->setFormat(tr("Very low"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184 } else {
230
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
185 double s1 = 20.0 / value;
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
186 if (value < 40) {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
187 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: 208
diff changeset
188 "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: 208
diff changeset
189 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: 208
diff changeset
190 } else {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
191 double s2 = 40.0 / value;
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
192 if (value < 60) {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
193 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: 208
diff changeset
194 "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: 208
diff changeset
195 ");}").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: 208
diff changeset
196 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: 208
diff changeset
197 } else {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
198 double s3 = 60.0 / value;
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
199 if (value < 80) {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
200 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: 208
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: 208
diff changeset
202 "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: 208
diff changeset
203 ");}").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: 208
diff changeset
204 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: 208
diff changeset
205 } else {
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
206 double s4 = 80.0 / value;
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
207 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: 208
diff changeset
208 "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: 208
diff changeset
209 "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: 208
diff changeset
210 ");}").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: 208
diff changeset
211 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: 208
diff changeset
212 }
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
213 }
b68c0c61d261 Rewritten the hop taste and aroma progress bars to use a gradient.
Michiel Broek <mbroek@mbse.eu>
parents: 208
diff changeset
214 }
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219 void EditRecipe::calcIBUs()
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
220 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
221 double hop_flavour = 0, hop_aroma = 0, ibus = 0;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
222
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
223 for (int i = 0; i < recipe->hops.size(); i++) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
224
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
225 ibus += Utils::toIBU(recipe->hops.at(i).useat, recipe->hops.at(i).form, recipe->preboil_sg, recipe->est_og, recipe->batch_size,
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
226 recipe->hops.at(i).amount,
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
227 recipe->hops.at(i).time, recipe->hops.at(i).alpha, recipe->ibu_method, 0, recipe->hops.at(i).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
228 0, recipe->boil_time, 0, 0, 0, recipe->hops.at(i).utilisation, recipe->hops.at(i).bu_factor);
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
229 hop_flavour += Utils::hopFlavourContribution(recipe->hops.at(i).time, recipe->batch_size, recipe->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
230 recipe->hops.at(i).amount, recipe->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
231 hop_aroma += Utils::hopAromaContribution(recipe->hops.at(i).time, recipe->batch_size, recipe->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
232 recipe->hops.at(i).amount, recipe->hops.at(i).form);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
233 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
234
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
235 hop_flavour = round(hop_flavour * 1000.0 / 5.0) / 10;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
236 hop_aroma = round(hop_aroma * 1000.0 / 6.0) / 10;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
237 if (hop_flavour > 100)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
238 hop_flavour = 100;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
239 if (hop_aroma > 100)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
240 hop_aroma = 100;
150
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
241 qDebug() << "ibu" << recipe->est_ibu << ibus << "flavour" << hop_flavour << "aroma" << hop_aroma << "method" << recipe->ibu_method;
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
242
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
243 recipe->est_ibu = ibus;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
244 ui->est_ibuEdit->setValue(recipe->est_ibu);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
245 ui->est_ibu2Edit->setValue(recipe->est_ibu);
151
b5b2483f3a3f New recipe, calculate the boil_size. Lot's of ignoreChanges removeals and where needed QSignalBlocker is used. Bottle priming calculation added. In fermentables editor block and release to100 settings only in mash to fermentation steps, bottle and kegging are ignored. Update the IBU slider after hop changes. Set the mash name when another mash profile is selected. Don't backup initial infuse amount if there was no mash table. A small cosmetic layout change on the mash tab.
Michiel Broek <mbroek@mbse.eu>
parents: 150
diff changeset
246 ui->est_ibuShow->setValue(recipe->est_ibu);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
247 ui->hop_tasteShow->setValue(hop_flavour);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
248 ui->hop_aromaShow->setValue(hop_aroma);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
249 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
250
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
251
139
f947c6988e91 Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
252 void EditRecipe::addHopRow_clicked()
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
253 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
254 Hops newh;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
255
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
256 qDebug() << "Add hop row";
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
257
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
258 for (int i = 0; i < recipe->hops.size(); i++) {
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
259 if (recipe->hops.at(i).amount == 0 && recipe->hops.at(i).alpha == 0)
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
260 return; // Add only one at a time.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
261 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
262
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
263 newh.name = "Select one";
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
264 newh.origin = "";
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
265 newh.amount = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
266 newh.cost = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
267 newh.type = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
268 newh.form = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
269 newh.useat = 2;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
270 newh.time = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
271 newh.alpha = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
272 newh.beta = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
273 newh.hsi = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
274 newh.humulene = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
275 newh.caryophyllene = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
276 newh.cohumulone = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
277 newh.myrcene = 0;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
278 newh.total_oil = 0;
376
81ae1b4e25db Edit Recipe Hop now properly updates the utilisation and bu_factor fields.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
279 newh.utilisation = 20;
81ae1b4e25db Edit Recipe Hop now properly updates the utilisation and bu_factor fields.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
280 newh.bu_factor = 1;
129
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
281
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
282 recipe->hops.append(newh);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
283 emit refreshAll();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
284 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
285
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
286
139
f947c6988e91 Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
287 void EditRecipe::deleteHopRow_clicked()
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
288 {
171
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 164
diff changeset
289 if (recipe->locked || recipe->hops.size() < 1)
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 164
diff changeset
290 return;
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 164
diff changeset
291
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
292 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
293 int row = pb->objectName().toInt();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
294 qDebug() << "Delete hop row" << row << recipe->hops.size();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
295
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
296 int rc = QMessageBox::warning(this, tr("Delete hop"), tr("Delete %1").arg(recipe->hops.at(row).name),
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
297 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
298 if (rc == QMessageBox::No)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
299 return;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
300
129
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
301 recipe->hops.removeAt(row);
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
302 is_changed();
a9c19eaab018 Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents: 127
diff changeset
303 emit refreshAll();
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
304 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
305
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
306
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
307 void EditRecipe::hop_amount_changed(double val)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
308 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
309 QTableWidgetItem *item;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
310
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
311 recipe->hops[recipe->hops_row].amount = val / 1000.0;
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
312 item = new QTableWidgetItem(QString("%1 gr").arg(val, 2, 'f', 1, '0'));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
313 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
314 ui->hopsTable->setItem(recipe->hops_row, 8, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
315
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
316 double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).useat, recipe->hops.at(recipe->hops_row).form, recipe->preboil_sg, recipe->est_og,
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
317 recipe->batch_size, recipe->hops.at(recipe->hops_row).amount, recipe->hops.at(recipe->hops_row).time,
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
318 recipe->hops.at(recipe->hops_row).alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).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
319 0, recipe->boil_time, 0, 0, 0, recipe->hops.at(recipe->hops_row).utilisation, recipe->hops.at(recipe->hops_row).bu_factor);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
320
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
321 ibuEdit->setValue(ibu);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
322 item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0'));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
323 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
324 ui->hopsTable->setItem(recipe->hops_row, 7, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
325
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
326 calcIBUs();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
327 is_changed();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
328 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
329
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
330
258
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
331 void EditRecipe::hop_alpha_changed(double val)
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
332 {
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
333 QTableWidgetItem *item;
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
334
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
335 recipe->hops[recipe->hops_row].alpha = val;
258
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
336 item = new QTableWidgetItem(QString("%1%").arg(val, 2, 'f', 1, '0'));
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
337 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
338 ui->hopsTable->setItem(recipe->hops_row, 4, item);
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
339
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
340 double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).useat, recipe->hops.at(recipe->hops_row).form, recipe->preboil_sg, recipe->est_og,
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
341 recipe->batch_size, recipe->hops.at(recipe->hops_row).amount, recipe->hops.at(recipe->hops_row).time,
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
342 recipe->hops.at(recipe->hops_row).alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).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
343 0, recipe->boil_time, 0, 0, 0, recipe->hops.at(recipe->hops_row).utilisation, recipe->hops.at(recipe->hops_row).bu_factor);
258
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
344
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
345 ibuEdit->setValue(ibu);
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
346 item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0'));
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
347 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
348 ui->hopsTable->setItem(recipe->hops_row, 7, item);
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
349
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
350 calcIBUs();
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
351 is_changed();
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
352 }
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
353
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
354
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
355 void EditRecipe::hop_time_changed(int val)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
356 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
357 QTableWidgetItem *item;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
358
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
359 if (recipe->hops.at(recipe->hops_row).useat == 2 || recipe->hops.at(recipe->hops_row).useat == 4) { // Boil or whirlpool
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
360 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: 263
diff changeset
361 recipe->hops[recipe->hops_row].time = val;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
362 } else if (recipe->hops.at(recipe->hops_row).useat == 5) { // Dry-hop
164
47ee0d1b47e9 Fixed dry-hop days setting.
Michiel Broek <mbroek@mbse.eu>
parents: 154
diff changeset
363 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: 263
diff changeset
364 recipe->hops[recipe->hops_row].time = val * 1440;
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
365 } else {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
366 item = new QTableWidgetItem(QString(""));
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
367 recipe->hops[recipe->hops_row].time = val;
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
368 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
369 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
370 ui->hopsTable->setItem(recipe->hops_row, 6, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
371
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
372 double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).useat, recipe->hops.at(recipe->hops_row).form, recipe->preboil_sg, recipe->est_og,
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
373 recipe->batch_size, recipe->hops.at(recipe->hops_row).amount, recipe->hops.at(recipe->hops_row).time,
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
374 recipe->hops.at(recipe->hops_row).alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).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
375 0, recipe->boil_time, 0, 0, 0, recipe->hops.at(recipe->hops_row).utilisation, recipe->hops.at(recipe->hops_row).bu_factor);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
376
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
377 ibuEdit->setValue(ibu);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
378 item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0'));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
379 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
380 ui->hopsTable->setItem(recipe->hops_row, 7, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
381
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
382 calcIBUs();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
383 is_changed();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
384 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
385
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
386
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
387 void EditRecipe::hop_select_changed(int val)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
388 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
389 QSqlQuery query;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
390 bool instock = hinstockEdit->isChecked();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
391 QString w;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
392 QTableWidgetItem *item;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
393
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
394 if (val < 1)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
395 return;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
396
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
397 /*
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
398 * Search the hop pointed by the index and instock flag.
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
399 */
376
81ae1b4e25db Edit Recipe Hop now properly updates the utilisation and bu_factor fields.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
400 QString sql = "SELECT * FROM inventory_hops ";
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
401 if (instock)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
402 sql.append("WHERE inventory > 0 ");
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
403 sql.append("ORDER BY origin,name");
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
404 query.prepare(sql);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
405 query.exec();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
406 query.first();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
407 for (int i = 0; i < (val - 1); i++) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
408 query.next();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
409 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
410
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
411 /*
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
412 * Replace the hop record contents
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
413 */
376
81ae1b4e25db Edit Recipe Hop now properly updates the utilisation and bu_factor fields.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
414 recipe->hops[recipe->hops_row].name = query.value("name").toString();
81ae1b4e25db Edit Recipe Hop now properly updates the utilisation and bu_factor fields.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
415 recipe->hops[recipe->hops_row].origin = query.value("origin").toString();
81ae1b4e25db Edit Recipe Hop now properly updates the utilisation and bu_factor fields.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
416 recipe->hops[recipe->hops_row].alpha = query.value("alpha").toDouble();
81ae1b4e25db Edit Recipe Hop now properly updates the utilisation and bu_factor fields.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
417 recipe->hops[recipe->hops_row].beta = query.value("beta").toDouble();
81ae1b4e25db Edit Recipe Hop now properly updates the utilisation and bu_factor fields.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
418 recipe->hops[recipe->hops_row].humulene = query.value("humulene").toDouble();
81ae1b4e25db Edit Recipe Hop now properly updates the utilisation and bu_factor fields.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
419 recipe->hops[recipe->hops_row].caryophyllene = query.value("caryophyllene").toDouble();
81ae1b4e25db Edit Recipe Hop now properly updates the utilisation and bu_factor fields.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
420 recipe->hops[recipe->hops_row].cohumulone = query.value("cohumulone").toDouble();
81ae1b4e25db Edit Recipe Hop now properly updates the utilisation and bu_factor fields.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
421 recipe->hops[recipe->hops_row].myrcene = query.value("myrcene").toDouble();
81ae1b4e25db Edit Recipe Hop now properly updates the utilisation and bu_factor fields.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
422 recipe->hops[recipe->hops_row].hsi = query.value("hsi").toDouble();
81ae1b4e25db Edit Recipe Hop now properly updates the utilisation and bu_factor fields.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
423 recipe->hops[recipe->hops_row].total_oil = query.value("total_oil").toDouble();
81ae1b4e25db Edit Recipe Hop now properly updates the utilisation and bu_factor fields.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
424 recipe->hops[recipe->hops_row].type = query.value("type").toInt();
81ae1b4e25db Edit Recipe Hop now properly updates the utilisation and bu_factor fields.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
425 recipe->hops[recipe->hops_row].form = query.value("form").toInt();
81ae1b4e25db Edit Recipe Hop now properly updates the utilisation and bu_factor fields.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
426 recipe->hops[recipe->hops_row].cost = query.value("cost").toDouble();
81ae1b4e25db Edit Recipe Hop now properly updates the utilisation and bu_factor fields.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
427 recipe->hops[recipe->hops_row].utilisation = query.value("utilisation").toDouble();
81ae1b4e25db Edit Recipe Hop now properly updates the utilisation and bu_factor fields.
Michiel Broek <mbroek@mbse.eu>
parents: 373
diff changeset
428 recipe->hops[recipe->hops_row].bu_factor = query.value("bu_factor").toDouble();
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
429
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
430 /*
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
431 * Update the visible fields
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
432 */
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
433 hnameEdit->setText(recipe->hops.at(recipe->hops_row).name);
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
434 horiginEdit->setText(recipe->hops.at(recipe->hops_row).origin);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
435
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
436 double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).useat, recipe->hops.at(recipe->hops_row).form, recipe->preboil_sg, recipe->est_og,
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
437 recipe->batch_size, recipe->hops.at(recipe->hops_row).amount, recipe->hops.at(recipe->hops_row).time,
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
438 recipe->hops.at(recipe->hops_row).alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).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
439 0, recipe->boil_time, 0, 0, 0, recipe->hops.at(recipe->hops_row).utilisation, recipe->hops.at(recipe->hops_row).bu_factor);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
440 ibuEdit->setValue(ibu);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
441
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
442 ui->hopsTable->setItem(recipe->hops_row, 0, new QTableWidgetItem(recipe->hops.at(recipe->hops_row).origin));
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
443 ui->hopsTable->setItem(recipe->hops_row, 1, new QTableWidgetItem(recipe->hops.at(recipe->hops_row).name));
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
444
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
445 QString hoptype = QCoreApplication::translate("HopTypes", g_hop_types[recipe->hops.at(recipe->hops_row).type]);
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
446 item = new QTableWidgetItem(hoptype);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
447 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
448 ui->hopsTable->setItem(recipe->hops_row, 2, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
449
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
450 item = new QTableWidgetItem(QCoreApplication::translate("HopForm", g_hop_forms[recipe->hops.at(recipe->hops_row).form]));
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
451 //item = new QTableWidgetItem(hop_forms[recipe->hops.at(recipe->hops_row).form]);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
452 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
453 ui->hopsTable->setItem(recipe->hops_row, 3, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
454
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
455 item = new QTableWidgetItem(QString("%1%").arg(recipe->hops.at(recipe->hops_row).alpha, 2, 'f', 1, '0'));
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
456 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
457 ui->hopsTable->setItem(recipe->hops_row, 4, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
458
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
459 item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0'));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
460 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
461 ui->hopsTable->setItem(recipe->hops_row, 7, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
462
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
463 calcIBUs();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
464 is_changed();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
465 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
466
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
467
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
468 void EditRecipe::hop_instock_changed(bool val)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
469 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
470 QSqlQuery query;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
471
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
472 this->hselectEdit->setCurrentIndex(-1);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
473 this->hselectEdit->clear();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
474 QString sql = "SELECT origin,name,alpha,inventory FROM inventory_hops ";
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
475 if (val)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
476 sql.append("WHERE inventory > 0 ");
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
477 sql.append("ORDER BY origin,name");
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
478 query.prepare(sql);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
479 query.exec();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
480 query.first();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
481 this->hselectEdit->addItem(""); // Start with empty value
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
482 for (int i = 0; i < query.size(); i++) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
483 this->hselectEdit->addItem(query.value(0).toString()+" - "+query.value(1).toString()+" ("+query.value(2).toString()+"%) "+
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
484 QString("%1 gr").arg(query.value(3).toDouble() * 1000.0, 2, 'f', 1, '0'));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
485 query.next();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
486 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
487 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
488
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
489
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
490 void EditRecipe::hop_useat_changed(int val)
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
491 {
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
492 recipe->hops[recipe->hops_row].useat = val;
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
493 QTableWidgetItem *item = new QTableWidgetItem(QCoreApplication::translate("HopUse", g_hop_useat[val]));
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
494 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
495 ui->hopsTable->setItem(recipe->hops_row, 5, item);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
496
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
497 if (val == 2 || val == 4) { // Boil or whirlpool
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
498 htimeLabel->setText(tr("Time in minutes:"));
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
499 htimeEdit->setValue(recipe->hops.at(recipe->hops_row).time);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
500 htimeEdit->setReadOnly(false);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
501 } else if (val == 5) { // Dry-hop
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
502 htimeLabel->setText(tr("Time in days:"));
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
503 htimeEdit->setValue(recipe->hops.at(recipe->hops_row).time / 1440);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
504 htimeEdit->setReadOnly(false);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
505 } else {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
506 htimeLabel->setText("");
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
507 htimeEdit->setValue(0);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
508 htimeEdit->setReadOnly(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
509 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
510
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
511 is_changed();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
512 emit refreshAll();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
513 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
514
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
515
258
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
516 void EditRecipe::hop_form_changed(int val)
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
517 {
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
518 recipe->hops[recipe->hops_row].form = val;
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 300
diff changeset
519 QTableWidgetItem *item = new QTableWidgetItem(QCoreApplication::translate("HopForm", g_hop_forms[val]));
258
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
520 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
521 ui->hopsTable->setItem(recipe->hops_row, 3, item);
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
522
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
523 double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).useat, recipe->hops.at(recipe->hops_row).form, recipe->preboil_sg, recipe->est_og,
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
524 recipe->batch_size, recipe->hops.at(recipe->hops_row).amount, recipe->hops.at(recipe->hops_row).time,
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
525 recipe->hops.at(recipe->hops_row).alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).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
526 0, recipe->boil_time, 0, 0, 0, recipe->hops.at(recipe->hops_row).utilisation, recipe->hops.at(recipe->hops_row).bu_factor);
258
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
527
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
528 ibuEdit->setValue(ibu);
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
529 item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0'));
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
530 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
531 ui->hopsTable->setItem(recipe->hops_row, 7, item);
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
532
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
533 is_changed();
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
534 emit refreshAll();
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
535 }
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
536
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
537
139
f947c6988e91 Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents: 131
diff changeset
538 void EditRecipe::editHopRow_clicked()
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
539 {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
540 QSqlQuery query;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
541
171
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 164
diff changeset
542 if (recipe->locked)
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 164
diff changeset
543 return;
6cd2d808d863 Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents: 164
diff changeset
544
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
545 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
546 recipe->hops_row = pb->objectName().toInt();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
547 qDebug() << "Edit hop row" << recipe->hops_row;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
548 Hops backup = recipe->hops.at(recipe->hops_row);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
549
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
550 QDialog* dialog = new QDialog(this);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
551 dialog->resize(738, 260);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
552 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
553 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
554 buttonBox->setGeometry(QRect(30, 210, 671, 32));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
555 buttonBox->setLayoutDirection(Qt::LeftToRight);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
556 buttonBox->setOrientation(Qt::Horizontal);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
557 buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
558 buttonBox->setCenterButtons(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
559 QLabel *nameLabel = new QLabel(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
560 nameLabel->setObjectName(QString::fromUtf8("nameLabel"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
561 nameLabel->setText(tr("Current hop:"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
562 nameLabel->setGeometry(QRect(10, 10, 141, 20));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
563 nameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
564 QLabel *originLabel = new QLabel(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
565 originLabel->setObjectName(QString::fromUtf8("originLabel"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
566 originLabel->setText(tr("Origin:"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
567 originLabel->setGeometry(QRect(10, 40, 141, 20));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
568 originLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
569 QLabel *amountLabel = new QLabel(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
570 amountLabel->setObjectName(QString::fromUtf8("amountLabel"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
571 amountLabel->setText(tr("Amount in gr:"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
572 amountLabel->setGeometry(QRect(10, 100, 141, 20));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
573 amountLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
258
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
574 QLabel *alphaLabel = new QLabel(dialog);
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
575 alphaLabel->setObjectName(QString::fromUtf8("alphaLabel"));
263
14d79ec33db4 Added Product copy to Product.
Michiel Broek <mbroek@mbse.eu>
parents: 258
diff changeset
576 alphaLabel->setText(tr("Alpha percent:"));
258
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
577 alphaLabel->setGeometry(QRect(420, 100, 121, 20));
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
578 alphaLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
579 htimeLabel = new QLabel(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
580 htimeLabel->setObjectName(QString::fromUtf8("htimeLabel"));
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
581 if (recipe->hops.at(recipe->hops_row).useat == 5) // Dry-hop
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
582 htimeLabel->setText(tr("Time in days:"));
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
583 else if (recipe->hops.at(recipe->hops_row).useat == 2 || recipe->hops.at(recipe->hops_row).useat == 4) // Boil or whirlpool
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
584 htimeLabel->setText(tr("Time in minutes:"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
585 else
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
586 htimeLabel->setText("");
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
587
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
588 htimeLabel->setGeometry(QRect(10, 130, 141, 20));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
589 htimeLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
590 QLabel *useatLabel = new QLabel(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
591 useatLabel->setObjectName(QString::fromUtf8("useatLabel"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
592 useatLabel->setText(tr("Use at:"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
593 useatLabel->setGeometry(QRect(10, 160, 141, 20));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
594 useatLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
258
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
595 QLabel *formLabel = new QLabel(dialog);
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
596 formLabel->setObjectName(QString::fromUtf8("formLabel"));
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
597 formLabel->setText(tr("Hop form:"));
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
598 formLabel->setGeometry(QRect(380, 160, 121, 20));
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
599 formLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
600 QLabel *selectLabel = new QLabel(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
601 selectLabel->setObjectName(QString::fromUtf8("selectLabel"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
602 selectLabel->setText(tr("Select hop:"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
603 selectLabel->setGeometry(QRect(10, 70, 141, 20));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
604 selectLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
605 QLabel *instockLabel = new QLabel(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
606 instockLabel->setObjectName(QString::fromUtf8("instockLabel"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
607 instockLabel->setText(tr("In stock:"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
608 instockLabel->setGeometry(QRect(525, 70, 121, 20));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
609 instockLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
610 QLabel *ibuLabel = new QLabel(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
611 ibuLabel->setObjectName(QString::fromUtf8("maxLabel"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
612 ibuLabel->setText(tr("Bitterness IBU:"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
613 ibuLabel->setGeometry(QRect(420, 130, 121, 20));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
614 ibuLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
615
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
616 hselectEdit = new QComboBox(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
617 hselectEdit->setObjectName(QString::fromUtf8("selectEdit"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
618 hselectEdit->setGeometry(QRect(160, 70, 371, 23));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
619
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
620 hnameEdit = new QLineEdit(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
621 hnameEdit->setObjectName(QString::fromUtf8("hnameEdit"));
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
622 hnameEdit->setText(recipe->hops.at(recipe->hops_row).name);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
623 hnameEdit->setGeometry(QRect(160, 10, 511, 23));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
624 hnameEdit->setReadOnly(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
625 horiginEdit = new QLineEdit(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
626 horiginEdit->setObjectName(QString::fromUtf8("horiginEdit"));
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
627 horiginEdit->setText(recipe->hops.at(recipe->hops_row).origin);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
628 horiginEdit->setGeometry(QRect(160, 40, 511, 23));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
629 horiginEdit->setReadOnly(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
630 hamountEdit = new QDoubleSpinBox(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
631 hamountEdit->setObjectName(QString::fromUtf8("hamountEdit"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
632 hamountEdit->setGeometry(QRect(160, 100, 121, 24));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
633 hamountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
634 hamountEdit->setAccelerated(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
635 hamountEdit->setDecimals(1);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
636 hamountEdit->setMaximum(1000000.0);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
637 hamountEdit->setSingleStep(0.5);
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
638 hamountEdit->setValue(recipe->hops.at(recipe->hops_row).amount * 1000.0);
258
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
639 halphaEdit = new QDoubleSpinBox(dialog);
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
640 halphaEdit->setObjectName(QString::fromUtf8("halphaEdit"));
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
641 halphaEdit->setGeometry(QRect(550, 100, 121, 24));
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
642 halphaEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
643 halphaEdit->setAccelerated(true);
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
644 halphaEdit->setDecimals(1);
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
645 halphaEdit->setMaximum(100.0);
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
646 halphaEdit->setSingleStep(0.1);
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
647 halphaEdit->setValue(recipe->hops.at(recipe->hops_row).alpha);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
648 htimeEdit = new QSpinBox(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
649 htimeEdit->setObjectName(QString::fromUtf8("htimeEdit"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
650 htimeEdit->setGeometry(QRect(160, 130, 121, 24));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
651 htimeEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
652 htimeEdit->setAccelerated(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
653 htimeEdit->setMaximum(10000.0);
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
654 if (recipe->hops.at(recipe->hops_row).useat == 2 || recipe->hops.at(recipe->hops_row).useat == 4) { // Boil or whirlpool
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
655 htimeEdit->setValue(recipe->hops.at(recipe->hops_row).time);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
656 htimeEdit->setReadOnly(false);
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
657 } else if (recipe->hops.at(recipe->hops_row).useat == 5){ // Dry-hop
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
658 htimeEdit->setValue(recipe->hops.at(recipe->hops_row).time / 1440);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
659 htimeEdit->setReadOnly(false);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
660 } else {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
661 htimeEdit->setReadOnly(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
662 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
663 useatEdit = new QComboBox(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
664 useatEdit->setObjectName(QString::fromUtf8("useatEdit"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
665 useatEdit->setGeometry(QRect(160, 160, 161, 23));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
666 useatEdit->addItem(tr("Mash"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
667 useatEdit->addItem(tr("First wort"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
668 useatEdit->addItem(tr("Boil"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
669 useatEdit->addItem(tr("Aroma"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
670 useatEdit->addItem(tr("Whirlpool"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
671 useatEdit->addItem(tr("Dry hop"));
300
2a97905cb637 Added hop co2 extract form. Added hop add at bottling needed for iso and tetra hop.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
672 useatEdit->addItem(tr("Bottling"));
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
673 useatEdit->setCurrentIndex(recipe->hops.at(recipe->hops_row).useat);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
674
258
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
675 hformEdit = new QComboBox(dialog);
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
676 hformEdit->setObjectName(QString::fromUtf8("formEdit"));
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
677 hformEdit->setGeometry(QRect(510, 160, 161, 23));
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
678 hformEdit->addItem(tr("Pellet"));
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
679 hformEdit->addItem(tr("Plug"));
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
680 hformEdit->addItem(tr("Leaf"));
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
681 hformEdit->addItem(tr("Wet leaf"));
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
682 hformEdit->addItem(tr("Cryo"));
300
2a97905cb637 Added hop co2 extract form. Added hop add at bottling needed for iso and tetra hop.
Michiel Broek <mbroek@mbse.eu>
parents: 282
diff changeset
683 hformEdit->addItem(tr("Extract"));
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
684 hformEdit->setCurrentIndex(recipe->hops.at(recipe->hops_row).form);
258
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
685
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
686 hinstockEdit = new QCheckBox(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
687 hinstockEdit->setObjectName(QString::fromUtf8("hinstockEdit"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
688 hinstockEdit->setGeometry(QRect(655, 70, 85, 21));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
689 hinstockEdit->setChecked(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
690
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
691 ibuEdit = new QDoubleSpinBox(dialog);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
692 ibuEdit->setObjectName(QString::fromUtf8("ibuEdit"));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
693 ibuEdit->setGeometry(QRect(550, 130, 121, 24));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
694 ibuEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
695 ibuEdit->setReadOnly(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
696 ibuEdit->setButtonSymbols(QAbstractSpinBox::NoButtons);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
697 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
698 double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).useat, recipe->hops.at(recipe->hops_row).form, recipe->preboil_sg, recipe->est_og,
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
699 recipe->batch_size, recipe->hops.at(recipe->hops_row).amount, recipe->hops.at(recipe->hops_row).time,
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
700 recipe->hops.at(recipe->hops_row).alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).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
701 0, recipe->boil_time, 0, 0, 0, recipe->hops.at(recipe->hops_row).utilisation, recipe->hops.at(recipe->hops_row).bu_factor);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
702 ibuEdit->setValue(ibu);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
703
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
704 hop_instock_changed(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
705
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
706 connect(hselectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::hop_select_changed);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
707 connect(hamountEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::hop_amount_changed);
258
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
708 connect(halphaEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::hop_alpha_changed);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
709 connect(htimeEdit, QOverload<int>::of(&QSpinBox::valueChanged), this, &EditRecipe::hop_time_changed);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
710 connect(useatEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::hop_useat_changed);
258
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
711 connect(hformEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::hop_form_changed);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
712 connect(hinstockEdit, &QCheckBox::stateChanged, this, &EditRecipe::hop_instock_changed);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
713 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
714 connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
715
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
716 dialog->setModal(true);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
717 dialog->exec();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
718 if (dialog->result() == QDialog::Rejected) {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
719 qDebug() << "reject and rollback";
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
720 recipe->hops[recipe->hops_row] = backup;
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
721 } else {
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
722 /* 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: 263
diff changeset
723 if (! (recipe->hops.at(recipe->hops_row).useat == 2 ||
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
724 recipe->hops.at(recipe->hops_row).useat == 4 ||
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
725 recipe->hops.at(recipe->hops_row).useat == 5)) {
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
726 if (recipe->hops.at(recipe->hops_row).time) {
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
727 recipe->hops[recipe->hops_row].time = 0;
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
728 is_changed();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
729 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
730 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
731 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
732
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
733 disconnect(hselectEdit, nullptr, nullptr, nullptr);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
734 disconnect(hamountEdit, nullptr, nullptr, nullptr);
258
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
735 disconnect(halphaEdit, nullptr, nullptr, nullptr);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
736 disconnect(htimeEdit, nullptr, nullptr, nullptr);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
737 disconnect(useatEdit, nullptr, nullptr, nullptr);
258
70bb9c3ee60f In the recipe editor hops you can now change the alpha percentage and hop form of any hop. We don't need locked values in recipe design.
Michiel Broek <mbroek@mbse.eu>
parents: 230
diff changeset
738 disconnect(hformEdit, nullptr, nullptr, nullptr);
127
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
739 disconnect(hinstockEdit, nullptr, nullptr, nullptr);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
740 disconnect(buttonBox, nullptr, nullptr, nullptr);
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
741
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
742 emit refreshAll();
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
743 }
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
744
475c8b8df67f Split recipes source in tabs.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
745
150
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
746 void EditRecipe::adjustHops(double factor)
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
747 {
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
748 double amount;
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
749
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
750 if (recipe->hops.size() == 0)
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
751 return;
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
752
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
753 for (int i = 0; i < recipe->hops.size(); i++) {
282
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
754 amount = recipe->hops.at(i).amount * factor;
d1d208a857b0 Member names for hops normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 263
diff changeset
755 recipe->hops[i].amount = amount;
150
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
756 }
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
757 }
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
758
fd568cc1dd0e Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents: 139
diff changeset
759

mercurial