Wed, 18 Oct 2023 16:00:06 +0200
Added application icon
127 | 1 | /** |
2 | * EditRecipe.cpp is part of bmsapp. | |
3 | * | |
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
|
4 | * Tab 2, fermentables |
127 | 5 | * |
6 | * bmsapp is free software: you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation, either version 3 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * bmsapp is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | */ | |
19 | ||
20 | ||
21 | ||
22 | bool EditRecipe::ferment_sort_test(const Fermentables &D1, const Fermentables &D2) | |
23 | { | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
24 | if (D1.added > D2.added) |
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
|
25 | return false; |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
26 | if (D1.added < D2.added) |
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
|
27 | return true; |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
28 | return (D1.amount >= D2.amount) && (D1.color < D2.color); |
127 | 29 | } |
30 | ||
31 | ||
32 | void EditRecipe::to100Fermentables(int row) | |
33 | { | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
34 | if (recipe->fermentables.at(row).adjust_to_total_100) { |
127 | 35 | QWidget *pWidget = new QWidget(); |
36 | QLabel *label = new QLabel; | |
37 | label->setPixmap(QPixmap(":icons/silk/tick.png")); | |
38 | QHBoxLayout *pLayout = new QHBoxLayout(pWidget); | |
39 | pLayout->addWidget(label); | |
40 | pLayout->setAlignment(Qt::AlignCenter); | |
41 | pLayout->setContentsMargins(0, 0, 0, 0); | |
42 | pWidget->setLayout(pLayout); | |
43 | ui->fermentablesTable->setCellWidget(row, 9, pWidget); | |
44 | } else { | |
45 | ui->fermentablesTable->removeCellWidget(row, 9); | |
46 | } | |
47 | } | |
48 | ||
49 | ||
50 | void EditRecipe::refreshFermentables() | |
51 | { | |
52 | QString w; | |
53 | QWidget* pWidget; | |
54 | QHBoxLayout* pLayout; | |
55 | QTableWidgetItem *item; | |
56 | ||
57 | std::sort(recipe->fermentables.begin(), recipe->fermentables.end(), ferment_sort_test); | |
58 | ||
59 | const QStringList labels({tr("Supplier"), tr("Fermentable"), tr("EBC"), tr("Type"), tr("Graintype"), tr("When"), tr("Yield"), | |
60 | tr("Amount"), tr("Procent"), tr("100%"), tr("Delete"), tr("Edit") }); | |
61 | ui->fermentablesTable->setColumnCount(12); | |
62 | ui->fermentablesTable->setColumnWidth(0, 150); /* Supplier */ | |
63 | ui->fermentablesTable->setColumnWidth(1, 225); /* Fermentable */ | |
64 | ui->fermentablesTable->setColumnWidth(2, 50); /* Color */ | |
65 | ui->fermentablesTable->setColumnWidth(3, 75); /* Type */ | |
66 | ui->fermentablesTable->setColumnWidth(4, 75); /* Graintype */ | |
67 | ui->fermentablesTable->setColumnWidth(5, 82); /* Added */ | |
68 | ui->fermentablesTable->setColumnWidth(6, 60); /* Yield */ | |
69 | ui->fermentablesTable->setColumnWidth(7, 90); /* Amount */ | |
70 | ui->fermentablesTable->setColumnWidth(8, 60); /* Procent */ | |
71 | ui->fermentablesTable->setColumnWidth(9, 50); /* 100% */ | |
72 | ui->fermentablesTable->setColumnWidth(10, 80); /* Delete */ | |
73 | ui->fermentablesTable->setColumnWidth(11, 80); /* Edit */ | |
74 | ui->fermentablesTable->setHorizontalHeaderLabels(labels); | |
75 | ui->fermentablesTable->verticalHeader()->hide(); | |
76 | ui->fermentablesTable->setRowCount(recipe->fermentables.size()); | |
77 | ||
78 | for (int i = 0; i < recipe->fermentables.size(); i++) { | |
79 | ||
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
80 | ui->fermentablesTable->setItem(i, 0, new QTableWidgetItem(recipe->fermentables.at(i).supplier)); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
81 | ui->fermentablesTable->setItem(i, 1, new QTableWidgetItem(recipe->fermentables.at(i).name)); |
127 | 82 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
83 | w = QString("%1").arg(recipe->fermentables.at(i).color, 1, 'f', 0, '0'); |
127 | 84 | item = new QTableWidgetItem(w); |
85 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
86 | ui->fermentablesTable->setItem(i, 2, item); | |
87 | ||
301
fe6346211b5b
Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents:
284
diff
changeset
|
88 | item = new QTableWidgetItem(QCoreApplication::translate("FermentableType", g_fermentable_types[recipe->fermentables.at(i).type])); |
127 | 89 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
90 | ui->fermentablesTable->setItem(i, 3, item); | |
91 | ||
301
fe6346211b5b
Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents:
284
diff
changeset
|
92 | item = new QTableWidgetItem(QCoreApplication::translate("FermentableGraintype", g_fermentable_graintypes[recipe->fermentables.at(i).graintype])); |
127 | 93 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
94 | ui->fermentablesTable->setItem(i, 4, item); | |
95 | ||
301
fe6346211b5b
Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents:
284
diff
changeset
|
96 | item = new QTableWidgetItem(QCoreApplication::translate("FermentableAdded", g_fermentable_added[recipe->fermentables.at(i).added])); |
127 | 97 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
98 | ui->fermentablesTable->setItem(i, 5, item); | |
99 | ||
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
100 | item = new QTableWidgetItem(QString("%1%").arg(recipe->fermentables.at(i).yield, 2, 'f', 1, '0')); |
127 | 101 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
102 | ui->fermentablesTable->setItem(i, 6, item); | |
103 | ||
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
104 | item = new QTableWidgetItem(QString("%1 Kg").arg(recipe->fermentables.at(i).amount, 4, 'f', 3, '0')); |
127 | 105 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
106 | ui->fermentablesTable->setItem(i, 7, item); | |
107 | ||
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
108 | if (recipe->fermentables.at(i).added < 4) { |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
109 | item = new QTableWidgetItem(QString("%1%").arg(recipe->fermentables.at(i).percentage, 2, 'f', 1, '0')); |
127 | 110 | } else { |
111 | item = new QTableWidgetItem(QString("")); // Blank for bottling and kegging. | |
112 | } | |
113 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
114 | ui->fermentablesTable->setItem(i, 8, item); | |
115 | ||
116 | to100Fermentables(i); | |
117 | ||
118 | /* Add the Delete row button */ | |
119 | pWidget = new QWidget(); | |
120 | QPushButton* btn_dele = new QPushButton(); | |
121 | btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */ | |
122 | 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:
132
diff
changeset
|
123 | connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteFermentRow_clicked())); |
127 | 124 | pLayout = new QHBoxLayout(pWidget); |
125 | pLayout->addWidget(btn_dele); | |
126 | pLayout->setContentsMargins(5, 0, 5, 0); | |
127 | pWidget->setLayout(pLayout); | |
128 | ui->fermentablesTable->setCellWidget(i, 10, pWidget); | |
129 | ||
130 | pWidget = new QWidget(); | |
131 | QPushButton* btn_edit = new QPushButton(); | |
132 | btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */ | |
133 | 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:
132
diff
changeset
|
134 | connect(btn_edit, SIGNAL(clicked()), this, SLOT(editFermentRow_clicked())); |
127 | 135 | pLayout = new QHBoxLayout(pWidget); |
136 | pLayout->addWidget(btn_edit); | |
137 | pLayout->setContentsMargins(5, 0, 5, 0); | |
138 | pWidget->setLayout(pLayout); | |
139 | ui->fermentablesTable->setCellWidget(i, 11, pWidget); | |
140 | } | |
141 | } | |
142 | ||
143 | ||
144 | void EditRecipe::calcFermentables() | |
145 | { | |
146 | int i; | |
147 | double psugar = 0, pcara = 0, d, s = 0, x, color; | |
148 | double vol = 0; // Volume sugars after boil | |
149 | double addedS = 0; // Added sugars after boil | |
150 | double addedmass = 0; // Added mass after boil | |
151 | double mvol = 0; // Mash volume | |
152 | double lintner = 0; // Total recipe lintner | |
153 | double sugarsf = 0; // fermentable sugars mash + boil | |
154 | double sugarsm = 0; // fermentable sugars in mash | |
155 | double sugardensity = 1.611; // kg/l in solution | |
156 | double mashtime = 0; // Total mash time | |
157 | double mashtemp = 0; // Average mash temperature | |
158 | double mashinfuse = 0; // Mash infuse amount | |
159 | double colort = 0; // Colors srm * vol totals | |
160 | double colorh = 0; // Colors ebc * vol * kt | |
161 | double colorn = 0; // Colors ebc * pt * pct | |
162 | ||
163 | qDebug() << "calcFermentables()"; | |
164 | ||
165 | /* | |
166 | * Get average mashtemp and mashtime from the Mash schedule. | |
167 | * It is possible that the schedule is not (yet) present. | |
168 | */ | |
169 | if (recipe->mashs.size() > 0) { | |
170 | for (i = 0; i < recipe->mashs.size(); i++) { | |
171 | if (recipe->mashs.at(i).step_type == 0) // Infusion | |
172 | mashinfuse += recipe->mashs.at(i).step_infuse_amount; | |
451
ccf00788bccc
Backported mash calculation from EditProduct to EditRecipe.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
173 | if (recipe->mashs.at(i).step_temp <= 75 && recipe->mashs.at(i).step_temp >= 60) { // Ignore mashout and low temperatures. |
ccf00788bccc
Backported mash calculation from EditProduct to EditRecipe.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
174 | double timem = recipe->mashs.at(i).step_time; |
ccf00788bccc
Backported mash calculation from EditProduct to EditRecipe.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
175 | if (i > 0) |
ccf00788bccc
Backported mash calculation from EditProduct to EditRecipe.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
176 | timem += recipe->mashs.at(i).ramp_time; |
ccf00788bccc
Backported mash calculation from EditProduct to EditRecipe.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
177 | mashtime += timem; |
ccf00788bccc
Backported mash calculation from EditProduct to EditRecipe.
Michiel Broek <mbroek@mbse.eu>
parents:
449
diff
changeset
|
178 | mashtemp += timem * recipe->mashs.at(i).step_temp; |
127 | 179 | } |
180 | } | |
181 | mashtemp = mashtemp / mashtime; | |
182 | mvol = mashinfuse; | |
183 | qDebug() << " mash time" << mashtime << "temp" << mashtemp << "infuse" << mashinfuse; | |
184 | } else { | |
185 | qDebug() << " no mash schedule"; | |
186 | } | |
187 | ||
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
|
188 | const QSignalBlocker blocker1(ui->est_ogEdit); |
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
|
189 | const QSignalBlocker blocker2(ui->est_og2Edit); |
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
|
190 | |
127 | 191 | if (recipe->fermentables.size() < 1) { |
192 | qDebug() << " no fermentables, return."; | |
193 | recipe->est_og = 0.980; | |
194 | ui->est_ogEdit->setValue(0.980); | |
195 | ui->est_og2Edit->setValue(0.980); | |
196 | ui->est_og3Edit->setValue(0.980); | |
197 | ui->est_ogShow->setValue(0.980); | |
198 | recipe->est_color = 0; | |
199 | ui->est_colorEdit->setValue(0); | |
200 | ui->est_colorEdit->setStyleSheet(Utils::ebc_to_style(0)); | |
201 | ui->est_color2Edit->setValue(0); | |
202 | ui->est_color2Edit->setStyleSheet(Utils::ebc_to_style(0)); | |
203 | ui->est_colorShow->setValue(0); | |
204 | ui->perc_mashShow->setValue(0); | |
205 | ui->perc_sugarsShow->setValue(0); | |
206 | ui->perc_caraShow->setValue(0); | |
207 | ui->lintnerShow->setValue(0); | |
208 | recipe->est_fg = 0.980; | |
209 | ui->est_fgEdit->setValue(0.980); | |
210 | ui->est_fg3Edit->setValue(0.980); | |
211 | ui->est_fgShow->setValue(0.980); | |
212 | ui->est_abvEdit->setValue(0); | |
213 | ui->est_abv2Edit->setValue(0); | |
214 | ui->est_abvShow->setValue(0); | |
215 | recipe->est_abv = 0; | |
216 | ui->calEdit->setValue(0); | |
148
ba25a566b100
Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
217 | recipe->mashs_kg = 0; |
127 | 218 | return; |
219 | } | |
220 | qDebug() << " adjust to 100" << recipe->fermentables_use100; | |
221 | ||
148
ba25a566b100
Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
222 | recipe->mashs_kg = 0; |
127 | 223 | for (i = 0; i < recipe->fermentables.size(); i++) { |
369
09d3d8d18f97
Version 0.2.20. Calculate total linther ignore malt color because our database is correct.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
224 | if (recipe->fermentables.at(i).type == FERMENTABLE_TYPE_SUGAR && recipe->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
225 | psugar += recipe->fermentables.at(i).percentage; |
369
09d3d8d18f97
Version 0.2.20. Calculate total linther ignore malt color because our database is correct.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
226 | if (recipe->fermentables.at(i).graintype == FERMENTABLE_GRAINTYPE_CRYSTAL && recipe->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
227 | pcara += recipe->fermentables.at(i).percentage; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
228 | d = recipe->fermentables.at(i).amount * (recipe->fermentables.at(i).yield / 100) * (1 - recipe->fermentables.at(i).moisture / 100); |
369
09d3d8d18f97
Version 0.2.20. Calculate total linther ignore malt color because our database is correct.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
229 | if (recipe->fermentables.at(i).added == FERMENTABLE_ADDED_MASH) { |
127 | 230 | if (mvol > 0) { // If mash volume is known |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
231 | mvol += recipe->fermentables.at(i).amount * recipe->fermentables.at(i).moisture / 100; |
127 | 232 | s += d; |
233 | } | |
234 | d = ui->efficiencyEdit->value() / 100 * d; | |
235 | sugarsm += d; | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
236 | recipe->mashs_kg += recipe->fermentables.at(i).amount; |
127 | 237 | } |
369
09d3d8d18f97
Version 0.2.20. Calculate total linther ignore malt color because our database is correct.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
238 | if (recipe->fermentables.at(i).added == FERMENTABLE_ADDED_MASH || recipe->fermentables.at(i).added == FERMENTABLE_ADDED_BOIL) |
127 | 239 | sugarsf += d; |
369
09d3d8d18f97
Version 0.2.20. Calculate total linther ignore malt color because our database is correct.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
240 | if (recipe->fermentables.at(i).added == FERMENTABLE_ADDED_FERMENTATION || recipe->fermentables.at(i).added == FERMENTABLE_ADDED_LAGERING) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
241 | x = (recipe->fermentables.at(i).yield / 100) * (1 - recipe->fermentables.at(i).moisture / 100); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
242 | addedS += recipe->fermentables.at(i).amount * x; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
243 | addedmass += recipe->fermentables.at(i).amount; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
244 | vol += (x * sugardensity + (1 - x) * 1) * recipe->fermentables.at(i).amount; |
127 | 245 | } |
369
09d3d8d18f97
Version 0.2.20. Calculate total linther ignore malt color because our database is correct.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
246 | if (recipe->fermentables.at(i).added == FERMENTABLE_ADDED_MASH && |
09d3d8d18f97
Version 0.2.20. Calculate total linther ignore malt color because our database is correct.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
247 | (recipe->fermentables.at(i).type == FERMENTABLE_TYPE_GRAIN || recipe->fermentables.at(i).type == FERMENTABLE_TYPE_ADJUCT)) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
248 | lintner += recipe->fermentables.at(i).diastatic_power * recipe->fermentables.at(i).amount; |
127 | 249 | } |
369
09d3d8d18f97
Version 0.2.20. Calculate total linther ignore malt color because our database is correct.
Michiel Broek <mbroek@mbse.eu>
parents:
301
diff
changeset
|
250 | if (recipe->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
251 | colort += recipe->fermentables.at(i).amount * Utils::ebc_to_srm(recipe->fermentables.at(i).color); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
252 | colorh += recipe->fermentables.at(i).amount * recipe->fermentables.at(i).color * Utils::get_kt(recipe->fermentables.at(i).color); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
253 | colorn += (recipe->fermentables.at(i).percentage / 100) * recipe->fermentables.at(i).color; // For 8.6 Pt wort. |
127 | 254 | } |
255 | } | |
256 | qDebug() << " colort" << colort << "colorh" << colorh << "colorn" << colorn; | |
257 | qDebug() << " psugar" << psugar << "pcara" << pcara << "mvol" << mvol; | |
258 | qDebug() << " sugarsf" << sugarsf << "sugarsm" << sugarsm; | |
259 | ||
167
5093db5665c6
Replaced ui variables by record variables.
Michiel Broek <mbroek@mbse.eu>
parents:
154
diff
changeset
|
260 | double og = Utils::estimate_sg(sugarsf + addedS, recipe->batch_size); |
127 | 261 | qDebug() << " OG" << ui->est_ogEdit->value() << og; |
262 | recipe->est_og = og; | |
263 | ui->est_ogEdit->setValue(og); | |
264 | ui->est_og2Edit->setValue(og); | |
265 | ui->est_og3Edit->setValue(og); | |
266 | ui->est_ogShow->setValue(og); | |
267 | ||
167
5093db5665c6
Replaced ui variables by record variables.
Michiel Broek <mbroek@mbse.eu>
parents:
154
diff
changeset
|
268 | recipe->preboil_sg = Utils::estimate_sg(sugarsm, recipe->boil_size); |
127 | 269 | qDebug() << " preboil SG" << recipe->preboil_sg; |
270 | ||
271 | /* | |
272 | * Color of the wort | |
273 | */ | |
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:
148
diff
changeset
|
274 | if (recipe->color_method == 4) { // Naudts |
167
5093db5665c6
Replaced ui variables by record variables.
Michiel Broek <mbroek@mbse.eu>
parents:
154
diff
changeset
|
275 | color = round(((Utils::sg_to_plato(og) / 8.6) * colorn) + (recipe->boil_time / 60)); |
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:
148
diff
changeset
|
276 | } else if (recipe->color_method == 3) { // Hans Halberstadt |
127 | 277 | double bv = 0.925; // Beer loss efficiency |
278 | double sr = 0.95; // Mash and sparge efficiency | |
167
5093db5665c6
Replaced ui variables by record variables.
Michiel Broek <mbroek@mbse.eu>
parents:
154
diff
changeset
|
279 | color = round((4.46 * bv * sr) / recipe->batch_size * colorh); |
127 | 280 | } else { |
167
5093db5665c6
Replaced ui variables by record variables.
Michiel Broek <mbroek@mbse.eu>
parents:
154
diff
changeset
|
281 | double cw = colort / recipe->batch_size * 8.34436; |
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:
148
diff
changeset
|
282 | color = Utils::kw_to_ebc(recipe->color_method, cw); |
168
4bc92122d001
Added kw_to_newebc function to debug EBC differences.
Michiel Broek <mbroek@mbse.eu>
parents:
167
diff
changeset
|
283 | //qDebug() << " oud EBC" << color << "new EBC" << Utils::kw_to_newebc(recipe->color_method, cw) << "SRM" << Utils::kw_to_srm(recipe->color_method, cw); |
127 | 284 | } |
285 | qDebug() << " color" << ui->est_colorEdit->value() << color << recipe->est_color; | |
286 | recipe->est_color = color; | |
287 | ui->est_colorEdit->setValue(color); | |
288 | ui->est_colorEdit->setStyleSheet(Utils::ebc_to_style(color)); | |
289 | ui->est_color2Edit->setValue(color); | |
290 | ui->est_color2Edit->setStyleSheet(Utils::ebc_to_style(color)); | |
291 | ui->est_colorShow->setValue(color); | |
292 | ||
293 | /* | |
294 | * We don't have a equipment profile in recipes, | |
295 | * so we assume a certain guessed mashtun size. | |
296 | */ | |
167
5093db5665c6
Replaced ui variables by record variables.
Michiel Broek <mbroek@mbse.eu>
parents:
154
diff
changeset
|
297 | ui->perc_mashShow->setValue(round(recipe->mashs_kg / (recipe->boil_size / 3) * 100)); |
127 | 298 | ui->perc_sugarsShow->setValue(round(psugar)); |
299 | ui->perc_caraShow->setValue(round(pcara)); | |
148
ba25a566b100
Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
300 | if (recipe->mashs_kg > 0) { |
ba25a566b100
Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
301 | qDebug() << " lintner" << lintner << " mashkg" << recipe->mashs_kg << "final" << round(lintner / recipe->mashs_kg); |
ba25a566b100
Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
302 | ui->lintnerShow->setValue(round(lintner / recipe->mashs_kg)); |
ba25a566b100
Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
303 | } else { |
ba25a566b100
Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
304 | qDebug() << " lintner N/A"; |
ba25a566b100
Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
305 | ui->lintnerShow->setValue(0); |
ba25a566b100
Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
306 | } |
127 | 307 | |
308 | /* | |
309 | * Calculate the apparant attenuation. | |
310 | */ | |
311 | double svg = 0; | |
449
00757c056ca6
With estimate_fg added a boolean parameter sta1 to correct the outcome if a primary yeast with sta1 gen is used. Fixed a spelling error in EditProduct yeast tab for dry yeast.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
312 | bool sta1 = false; |
127 | 313 | if (recipe->yeasts.size() > 0) { |
314 | for (i = 0; i < recipe->yeasts.size(); i++) { | |
284
33bb98c33e6a
Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
283
diff
changeset
|
315 | if (recipe->yeasts.at(i).use == 0) { // Used in primary |
33bb98c33e6a
Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
283
diff
changeset
|
316 | if (recipe->yeasts.at(i).attenuation > svg) |
33bb98c33e6a
Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
283
diff
changeset
|
317 | svg = recipe->yeasts.at(i).attenuation; // Take the highest if multiple yeasts. |
449
00757c056ca6
With estimate_fg added a boolean parameter sta1 to correct the outcome if a primary yeast with sta1 gen is used. Fixed a spelling error in EditProduct yeast tab for dry yeast.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
318 | if (recipe->yeasts.at(i).sta1) |
00757c056ca6
With estimate_fg added a boolean parameter sta1 to correct the outcome if a primary yeast with sta1 gen is used. Fixed a spelling error in EditProduct yeast tab for dry yeast.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
319 | sta1 = true; |
127 | 320 | } |
321 | // TODO: brett or others in secondary. | |
322 | } | |
323 | qDebug() << " SVG" << svg; | |
324 | } | |
325 | if (svg == 0) | |
326 | svg = 77.0; | |
142
1caa15a0eefc
Added calcYeast(). Added show svg from calcFermentables() on the yeast tab. Fixed wrong data displayed in the yeast table. Show estimated needed dry yeast or starters.
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
327 | ui->est_svgEdit->setValue(svg); |
127 | 328 | |
329 | double fg; | |
148
ba25a566b100
Added calcMash(). Display total mash time.
Michiel Broek <mbroek@mbse.eu>
parents:
142
diff
changeset
|
330 | if (recipe->mashs_kg > 0 && mashinfuse > 0 && mashtime > 0 && mashtemp > 0) |
449
00757c056ca6
With estimate_fg added a boolean parameter sta1 to correct the outcome if a primary yeast with sta1 gen is used. Fixed a spelling error in EditProduct yeast tab for dry yeast.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
331 | fg = Utils::estimate_fg(psugar, pcara, mashinfuse / recipe->mashs_kg, mashtime, mashtemp, svg, og, sta1); |
127 | 332 | else |
449
00757c056ca6
With estimate_fg added a boolean parameter sta1 to correct the outcome if a primary yeast with sta1 gen is used. Fixed a spelling error in EditProduct yeast tab for dry yeast.
Michiel Broek <mbroek@mbse.eu>
parents:
369
diff
changeset
|
333 | fg = Utils::estimate_fg(psugar, pcara, 0, 0, 0, svg, og, sta1); |
127 | 334 | qDebug() << " FG" << ui->est_fgEdit->value() << fg; |
335 | recipe->est_fg = fg; | |
336 | ui->est_fgEdit->setValue(fg); | |
337 | ui->est_fg3Edit->setValue(fg); | |
338 | ui->est_fgShow->setValue(fg); | |
339 | ||
340 | double abv = Utils::abvol(og, fg); | |
341 | qDebug() << " ABV" << ui->est_abvEdit->value() << abv; | |
342 | ui->est_abvEdit->setValue(abv); | |
343 | ui->est_abv2Edit->setValue(abv); | |
344 | ui->est_abvShow->setValue(abv); | |
345 | recipe->est_abv = abv; | |
346 | ||
347 | /* | |
348 | * Calculate kilocalories/liter. Formula from brouwhulp. | |
349 | * Take the alcohol and sugar parts and then combine. | |
350 | */ | |
351 | double alc = 1881.22 * fg * (og - fg) / (1.775 - og); | |
352 | double sug = 3550 * fg * (0.1808 * og + 0.8192 * fg - 1.0004); | |
353 | ui->calEdit->setValue(round((alc + sug) / (12 * 0.0295735296))); | |
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
|
354 | |
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
|
355 | // Bottle priming |
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
|
356 | double priming_total = 0; |
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
|
357 | for (i = 0; i < recipe->fermentables.size(); i++) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
358 | if (recipe->fermentables.at(i).added == 4) { |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
359 | priming_total += ((recipe->fermentables.at(i).yield / 100) * (1 - recipe->fermentables.at(i).moisture / 100)) * |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
360 | recipe->fermentables.at(i).amount; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
361 | qDebug() << " priming" << recipe->fermentables.at(i).amount << "total" << priming_total; |
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
|
362 | } |
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
|
363 | } |
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
|
364 | double grl = priming_total * 1000.0 * (1 / recipe->batch_size); |
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
|
365 | double volco2 = grl * 0.510; |
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
|
366 | qDebug() << " priming gr/l" << grl << "volco2" << volco2; |
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
|
367 | |
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
|
368 | if (volco2 > 0) { |
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
|
369 | recipe->est_carb = volco2; |
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
|
370 | ui->est_carbEdit->setValue(recipe->est_carb); |
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
|
371 | ui->est_carbShow->setValue(recipe->est_carb); |
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
|
372 | } |
127 | 373 | } |
374 | ||
375 | ||
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:
148
diff
changeset
|
376 | void EditRecipe::calcFermentablesFromOG(double og) |
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:
148
diff
changeset
|
377 | { |
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:
148
diff
changeset
|
378 | qDebug() << "calcFermentablesFromOG" << og; |
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:
148
diff
changeset
|
379 | |
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:
148
diff
changeset
|
380 | int i; |
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:
148
diff
changeset
|
381 | double totmass = 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:
148
diff
changeset
|
382 | double tot = 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:
148
diff
changeset
|
383 | double d, 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:
148
diff
changeset
|
384 | double efficiency = recipe->efficiency; |
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:
148
diff
changeset
|
385 | double sug = Utils::sg_to_plato(og) * recipe->batch_size * og / 100.0; // total amount of sugars in kg. |
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:
148
diff
changeset
|
386 | |
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:
148
diff
changeset
|
387 | for (i = 0; i < recipe->fermentables.size(); i++) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
388 | if (recipe->fermentables.at(i).added < 4) { |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
389 | d = recipe->fermentables.at(i).percentage / 100.0 * |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
390 | (recipe->fermentables.at(i).yield / 100.0) * |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
391 | (1 - recipe->fermentables.at(i).moisture / 100.0); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
392 | if (recipe->fermentables.at(i).added == 0) // Mash |
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:
148
diff
changeset
|
393 | d = efficiency / 100.0 * d; |
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:
148
diff
changeset
|
394 | tot += d; |
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:
148
diff
changeset
|
395 | } |
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:
148
diff
changeset
|
396 | } |
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:
148
diff
changeset
|
397 | if (tot) |
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:
148
diff
changeset
|
398 | totmass = round((sug / tot) * 1000.0) / 1000.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:
148
diff
changeset
|
399 | |
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:
148
diff
changeset
|
400 | if (totmass) { |
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:
148
diff
changeset
|
401 | for (i = 0; i < recipe->fermentables.size(); i++) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
402 | amount = round(recipe->fermentables.at(i).percentage * 10.0 * totmass) / 1000.0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
403 | recipe->fermentables[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:
148
diff
changeset
|
404 | } |
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:
148
diff
changeset
|
405 | } |
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:
148
diff
changeset
|
406 | } |
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:
148
diff
changeset
|
407 | |
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:
148
diff
changeset
|
408 | |
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:
132
diff
changeset
|
409 | void EditRecipe::ferment_perc_mash_valueChanged(int value) |
127 | 410 | { |
229
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
411 | if (value < 90) { |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
412 | ui->perc_mashShow->setStyleSheet(bar_green); |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
413 | } else { |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
414 | double s1 = 90.0 / value; |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
415 | if (value < 100) { |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
416 | ui->perc_mashShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, " |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
417 | "stop: 0 green, stop: %1 green, stop: %2 orange, stop: 1 orange" |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
418 | ");}").arg(s1 - 0.00001).arg(s1)); |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
419 | } else { |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
420 | double s2 = 100.0 / value; |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
421 | ui->perc_mashShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, " |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
422 | "stop: 0 green, stop: %1 green, stop: %2 orange, stop: %3 orange, stop: %4 red, stop: 1 red" |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
423 | ");}").arg(s1 - 0.00003).arg(s1 - 0.00002).arg(s2 - 0.00001).arg(s2)); |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
424 | } |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
425 | } |
127 | 426 | } |
427 | ||
428 | ||
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:
132
diff
changeset
|
429 | void EditRecipe::ferment_perc_sugars_valueChanged(int value) |
127 | 430 | { |
431 | if (value < 20) | |
229
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
432 | ui->perc_sugarsShow->setStyleSheet(bar_green); |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
433 | else { |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
434 | double s1 = 20.0 / value; |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
435 | ui->perc_sugarsShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, " |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
436 | "stop: 0 green, stop: %1 green, stop: %2 red, stop: 1 red);}").arg(s1 - 0.00001).arg(s1)); |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
437 | } |
127 | 438 | } |
439 | ||
440 | ||
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:
132
diff
changeset
|
441 | void EditRecipe::ferment_perc_cara_valueChanged(int value) |
127 | 442 | { |
443 | if (value < 25) | |
229
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
444 | ui->perc_caraShow->setStyleSheet(bar_green); |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
445 | else { |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
446 | double s1 = 25.0 / value; |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
447 | ui->perc_caraShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, " |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
448 | "stop: 0 green, stop: %1 green, stop: %2 red, stop: 1 red);}").arg(s1 - 0.00001).arg(s1)); |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
449 | } |
127 | 450 | } |
451 | ||
452 | ||
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:
132
diff
changeset
|
453 | void EditRecipe::ferment_lintner_valueChanged(int value) |
127 | 454 | { |
229
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
455 | /* |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
456 | * Calculate the color stop positions |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
457 | */ |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
458 | if (value < 30) { |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
459 | ui->lintnerShow->setStyleSheet(bar_red); |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
460 | } else { |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
461 | double s1 = 30.0 / value; |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
462 | if (value < 40) { |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
463 | ui->lintnerShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, " |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
464 | "stop: 0 red, stop: %1 red, stop: %2 orange, stop: 1 orange);}").arg(s1 - 0.00001).arg(s1)); |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
465 | } else { |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
466 | double s2 = 40.0 / value; |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
467 | ui->lintnerShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, " |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
468 | "stop: 0 red, stop: %1 red, stop: %2 orange, stop: %3 orange, stop: %4 green, stop: 1 green" |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
469 | ");}").arg(s1 - 0.00003).arg(s1 - 0.00002).arg(s2 - 0.00001).arg(s2)); |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
470 | } |
815ee118ad49
The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
471 | } |
127 | 472 | } |
473 | ||
474 | ||
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:
132
diff
changeset
|
475 | void EditRecipe::addFermentRow_clicked() |
127 | 476 | { |
477 | Fermentables newf; | |
478 | ||
479 | qDebug() << "Add fermentable row"; | |
480 | ||
481 | for (int i = 0; i < recipe->fermentables.size(); i++) { | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
482 | if (recipe->fermentables.at(i).amount == 0 && recipe->fermentables.at(i).color == 0) |
127 | 483 | return; // Add only one at a time. |
484 | } | |
485 | ||
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
486 | newf.name = "Select one"; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
487 | newf.origin = ""; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
488 | newf.supplier = ""; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
489 | newf.amount = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
490 | newf.cost = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
491 | newf.type = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
492 | newf.yield = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
493 | newf.color = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
494 | newf.coarse_fine_diff = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
495 | newf.moisture = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
496 | newf.diastatic_power = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
497 | newf.protein = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
498 | newf.dissolved_protein = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
499 | newf.max_in_batch = 100; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
500 | newf.graintype = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
501 | newf.added = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
502 | newf.recommend_mash = true; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
503 | newf.add_after_boil = false; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
504 | newf.adjust_to_total_100 = false; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
505 | newf.percentage = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
506 | newf.di_ph = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
507 | newf.acid_to_ph_57 = 0; |
127 | 508 | |
509 | recipe->fermentables.append(newf); | |
510 | emit refreshAll(); | |
511 | } | |
512 | ||
513 | ||
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:
132
diff
changeset
|
514 | void EditRecipe::deleteFermentRow_clicked() |
127 | 515 | { |
171
6cd2d808d863
Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents:
168
diff
changeset
|
516 | if (recipe->locked) |
6cd2d808d863
Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents:
168
diff
changeset
|
517 | return; |
6cd2d808d863
Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents:
168
diff
changeset
|
518 | |
127 | 519 | QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); |
520 | int row = pb->objectName().toInt(); | |
521 | qDebug() << "Delete fermentable row" << row << recipe->fermentables.size(); | |
522 | ||
523 | if (recipe->fermentables.size() < 1) | |
524 | return; | |
525 | ||
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
526 | int rc = QMessageBox::warning(this, tr("Delete fermentable"), tr("Delete %1").arg(recipe->fermentables.at(row).name), |
127 | 527 | QMessageBox::Yes | QMessageBox::No, QMessageBox::No); |
528 | if (rc == QMessageBox::No) | |
529 | return; | |
530 | ||
531 | recipe->fermentables.removeAt(row); | |
532 | ||
533 | /* | |
534 | * Recalculate the percentages on the rows left. | |
535 | */ | |
536 | double total = 0; | |
537 | for (int i = 0; i < recipe->fermentables.size(); i++) | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
538 | if (recipe->fermentables.at(i).added < 4) // Only before bottle/kegging |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
539 | total += recipe->fermentables.at(i).amount; |
127 | 540 | for (int i = 0; i < recipe->fermentables.size(); i++) |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
541 | if (recipe->fermentables.at(i).added < 4) |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
542 | recipe->fermentables[i].percentage = recipe->fermentables.at(i).amount / total * 100; |
127 | 543 | |
132
9ede9c75cb54
Added miscs popup editor. No edit functions yet. Delete misc row added.
Michiel Broek <mbroek@mbse.eu>
parents:
129
diff
changeset
|
544 | is_changed(); |
127 | 545 | emit refreshAll(); |
546 | } | |
547 | ||
548 | ||
549 | void EditRecipe::ferment_amount_changed(double val) | |
550 | { | |
551 | QTableWidgetItem *item; | |
552 | double total = 0, perc; | |
553 | ||
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
554 | if (recipe->fermentables_use100 && recipe->fermentables.at(recipe->fermentables_row).added < 4) |
127 | 555 | return; |
556 | ||
557 | qDebug() << "ferment_amount_changed()" << recipe->fermentables_row << val; | |
558 | ||
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
559 | recipe->fermentables[recipe->fermentables_row].amount = val; |
127 | 560 | item = new QTableWidgetItem(QString("%1 Kg").arg(val, 4, 'f', 3, '0')); |
561 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
562 | ui->fermentablesTable->setItem(recipe->fermentables_row, 7, item); | |
563 | ||
564 | for (int i = 0; i < recipe->fermentables.size(); i++) | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
565 | if (recipe->fermentables.at(i).added < 4) // Only before bottle/kegging |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
566 | total += recipe->fermentables.at(i).amount; |
127 | 567 | /* |
568 | * Recalculate the percentages | |
569 | */ | |
570 | for (int i = 0; i < recipe->fermentables.size(); i++) { | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
571 | if (recipe->fermentables.at(i).added < 4) { |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
572 | perc = recipe->fermentables.at(i).amount / total * 100; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
573 | recipe->fermentables[i].percentage = perc; |
127 | 574 | item = new QTableWidgetItem(QString("%1%").arg(perc, 2, 'f', 1, '0')); |
575 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
576 | ui->fermentablesTable->setItem(i, 8, item); | |
577 | if (i == recipe->fermentables_row) | |
578 | this->pctEdit->setValue(perc); | |
579 | } | |
580 | } | |
581 | is_changed(); | |
582 | } | |
583 | ||
584 | ||
585 | void EditRecipe::ferment_pct_changed(double val) | |
586 | { | |
587 | QTableWidgetItem *item; | |
588 | double total = 0, row100 = -1; | |
589 | ||
590 | if (! recipe->fermentables_use100) | |
591 | return; | |
592 | ||
593 | qDebug() << "ferment_pct_changed()" << recipe->fermentables_row << val; | |
594 | /* | |
595 | * Since we have arrived here, adjust_to_100 is active and | |
596 | * this is not the entry to be adjusted to 100. | |
597 | */ | |
598 | for (int i = 0; i < recipe->fermentables.size(); i++) { | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
599 | if (recipe->fermentables.at(i).added < 4) // Only before bottle/kegging |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
600 | total += recipe->fermentables.at(i).amount; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
601 | if (recipe->fermentables.at(i).adjust_to_total_100) |
127 | 602 | row100 = i; |
603 | } | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
604 | double oldperc = recipe->fermentables.at(recipe->fermentables_row).percentage; |
127 | 605 | double diffp = val - oldperc; |
606 | double diffw = (diffp / 100) * total; | |
607 | qDebug() << "row100" << row100 << "total" << total << "diff kg" << diffw << "diff %" << diffp; | |
608 | ||
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
609 | recipe->fermentables[recipe->fermentables_row].percentage += diffp; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
610 | recipe->fermentables[recipe->fermentables_row].amount += diffw; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
611 | recipe->fermentables[row100].percentage -= diffp; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
612 | recipe->fermentables[row100].amount -= diffw; |
127 | 613 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
614 | item = new QTableWidgetItem(QString("%1 Kg").arg(recipe->fermentables[recipe->fermentables_row].amount, 4, 'f', 3, '0')); |
127 | 615 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
616 | ui->fermentablesTable->setItem(recipe->fermentables_row, 7, item); | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
617 | this->famountEdit->setValue(recipe->fermentables[recipe->fermentables_row].amount); |
127 | 618 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
619 | item = new QTableWidgetItem(QString("%1%").arg(recipe->fermentables[recipe->fermentables_row].percentage, 2, 'f', 1, '0')); |
127 | 620 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
621 | ui->fermentablesTable->setItem(recipe->fermentables_row, 8, item); | |
622 | ||
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
623 | item = new QTableWidgetItem(QString("%1 Kg").arg(recipe->fermentables[row100].amount, 4, 'f', 3, '0')); |
127 | 624 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
625 | ui->fermentablesTable->setItem(row100, 7, item); | |
626 | ||
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
627 | item = new QTableWidgetItem(QString("%1%").arg(recipe->fermentables[row100].percentage, 2, 'f', 1, '0')); |
127 | 628 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
629 | ui->fermentablesTable->setItem(row100, 8, item); | |
630 | ||
631 | is_changed(); | |
632 | } | |
633 | ||
634 | ||
635 | void EditRecipe::ferment_to100_changed(bool val) | |
636 | { | |
637 | qDebug() << "ferment_to100_changed()" << recipe->fermentables_row << val << recipe->fermentables_use100; | |
638 | ||
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
639 | if (recipe->fermentables.at(recipe->fermentables_row).added >= 4) { |
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
|
640 | const QSignalBlocker blocker1(to100Edit); |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
641 | recipe->fermentables[recipe->fermentables_row].adjust_to_total_100 = false; |
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
|
642 | to100Edit->setChecked(false); |
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
|
643 | return; |
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
|
644 | } |
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
|
645 | |
127 | 646 | /* |
647 | * Three scenario's. | |
648 | * 1. There is no fermentable selected yet, just mark it. | |
649 | * 2. There is current one is selected, deselect it. | |
650 | * 3. There is another one selected, deselect and select this one. | |
651 | */ | |
652 | if (! recipe->fermentables_use100 && val) { | |
653 | /* Scenario 1. */ | |
654 | recipe->fermentables_use100 = true; | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
655 | recipe->fermentables[recipe->fermentables_row].adjust_to_total_100 = true; |
127 | 656 | pctEdit->setReadOnly(false); |
657 | famountEdit->setReadOnly(true); | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
658 | } else if (recipe->fermentables_use100 && recipe->fermentables[recipe->fermentables_row].adjust_to_total_100 && ! val) { |
127 | 659 | /* Scenario 2. */ |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
660 | recipe->fermentables[recipe->fermentables_row].adjust_to_total_100 = false; |
127 | 661 | recipe->fermentables_use100 = false; |
662 | pctEdit->setReadOnly(true); | |
663 | famountEdit->setReadOnly(false); | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
664 | } else if (recipe->fermentables_use100 && ! recipe->fermentables[recipe->fermentables_row].adjust_to_total_100 && val) { |
127 | 665 | /* Scenario 3. */ |
666 | for (int i = 0; i < recipe->fermentables.size(); i++) { | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
667 | recipe->fermentables[i].adjust_to_total_100 = false; |
127 | 668 | } |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
669 | recipe->fermentables[recipe->fermentables_row].adjust_to_total_100 = true; |
127 | 670 | } else { |
671 | qDebug() << "bug"; | |
672 | return; | |
673 | } | |
674 | ||
675 | for (int i = 0; i < recipe->fermentables.size(); i++) { | |
676 | to100Fermentables(i); | |
677 | } | |
678 | is_changed(); | |
679 | } | |
680 | ||
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
|
681 | |
127 | 682 | void EditRecipe::ferment_select_changed(int val) |
683 | { | |
684 | QSqlQuery query; | |
685 | bool instock = finstockEdit->isChecked(); | |
686 | QString w; | |
687 | QTableWidgetItem *item; | |
688 | ||
689 | if (val < 1) | |
690 | return; | |
691 | ||
692 | qDebug() << "ferment_select_changed()" << recipe->fermentables_row << val << instock; | |
693 | ||
694 | /* | |
695 | * Search the fermentable pointed by the index and instock flag. | |
696 | */ | |
697 | QString sql = "SELECT name,origin,supplier,cost,type,yield,color,coarse_fine_diff,moisture,diastatic_power,protein,dissolved_protein,max_in_batch," | |
698 | "graintype,recommend_mash,add_after_boil,di_ph,acid_to_ph_57 FROM inventory_fermentables "; | |
699 | if (instock) | |
700 | sql.append("WHERE inventory > 0 "); | |
701 | sql.append("ORDER BY supplier,name"); | |
702 | query.prepare(sql); | |
703 | query.exec(); | |
704 | query.first(); | |
705 | for (int i = 0; i < (val - 1); i++) { | |
706 | query.next(); | |
707 | } | |
708 | qDebug() << "found" << query.value(2).toString() << query.value(0).toString(); | |
709 | ||
710 | /* | |
711 | * Replace the fermentable record contents | |
712 | */ | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
713 | recipe->fermentables[recipe->fermentables_row].name = query.value(0).toString(); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
714 | recipe->fermentables[recipe->fermentables_row].origin = query.value(1).toString(); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
715 | recipe->fermentables[recipe->fermentables_row].supplier = query.value(2).toString(); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
716 | recipe->fermentables[recipe->fermentables_row].cost = query.value(3).toDouble(); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
717 | recipe->fermentables[recipe->fermentables_row].type = query.value(4).toInt(); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
718 | recipe->fermentables[recipe->fermentables_row].yield = query.value(5).toDouble(); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
719 | recipe->fermentables[recipe->fermentables_row].color = query.value(6).toDouble(); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
720 | recipe->fermentables[recipe->fermentables_row].coarse_fine_diff = query.value(7).toDouble(); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
721 | recipe->fermentables[recipe->fermentables_row].moisture = query.value(8).toDouble(); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
722 | recipe->fermentables[recipe->fermentables_row].diastatic_power = query.value(9).toDouble(); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
723 | recipe->fermentables[recipe->fermentables_row].protein = query.value(10).toDouble(); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
724 | recipe->fermentables[recipe->fermentables_row].dissolved_protein = query.value(11).toDouble(); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
725 | recipe->fermentables[recipe->fermentables_row].max_in_batch = query.value(12).toDouble(); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
726 | recipe->fermentables[recipe->fermentables_row].graintype = query.value(13).toInt(); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
727 | recipe->fermentables[recipe->fermentables_row].recommend_mash = query.value(14).toInt() ? true:false; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
728 | recipe->fermentables[recipe->fermentables_row].add_after_boil = query.value(15).toInt() ? true:false; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
729 | recipe->fermentables[recipe->fermentables_row].di_ph = query.value(16).toDouble(); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
730 | recipe->fermentables[recipe->fermentables_row].acid_to_ph_57 = query.value(17).toDouble(); |
127 | 731 | |
732 | /* | |
733 | * Update the visible fields | |
734 | */ | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
735 | fnameEdit->setText(recipe->fermentables.at(recipe->fermentables_row).name); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
736 | fsupplierEdit->setText(recipe->fermentables.at(recipe->fermentables_row).supplier); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
737 | fmaxEdit->setValue(recipe->fermentables.at(recipe->fermentables_row).max_in_batch); |
127 | 738 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
739 | ui->fermentablesTable->setItem(recipe->fermentables_row, 0, new QTableWidgetItem(recipe->fermentables.at(recipe->fermentables_row).supplier)); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
740 | ui->fermentablesTable->setItem(recipe->fermentables_row, 1, new QTableWidgetItem(recipe->fermentables.at(recipe->fermentables_row).name)); |
127 | 741 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
742 | w = QString("%1").arg(recipe->fermentables.at(recipe->fermentables_row).color, 1, 'f', 0, '0'); |
127 | 743 | item = new QTableWidgetItem(w); |
744 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
745 | ui->fermentablesTable->setItem(recipe->fermentables_row, 2, item); | |
746 | ||
301
fe6346211b5b
Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents:
284
diff
changeset
|
747 | item = new QTableWidgetItem(QCoreApplication::translate("FermentableType", g_fermentable_types[recipe->fermentables.at(recipe->fermentables_row).type])); |
127 | 748 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
749 | ui->fermentablesTable->setItem(recipe->fermentables_row, 3, item); | |
750 | ||
301
fe6346211b5b
Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents:
284
diff
changeset
|
751 | item = new QTableWidgetItem(QCoreApplication::translate("FermentableGraintype", g_fermentable_graintypes[recipe->fermentables.at(recipe->fermentables_row).graintype])); |
127 | 752 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
753 | ui->fermentablesTable->setItem(recipe->fermentables_row, 4, item); | |
754 | ||
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
755 | item = new QTableWidgetItem(QString("%1%").arg(recipe->fermentables.at(recipe->fermentables_row).yield, 2, 'f', 1, '0')); |
127 | 756 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
757 | ui->fermentablesTable->setItem(recipe->fermentables_row, 6, item); | |
758 | ||
759 | calcFermentables(); | |
760 | is_changed(); | |
761 | } | |
762 | ||
763 | ||
764 | void EditRecipe::ferment_instock_changed(bool val) | |
765 | { | |
766 | QSqlQuery query; | |
767 | ||
768 | qDebug() << "ferment_instock_changed()" << recipe->fermentables_row << val; | |
769 | ||
770 | this->fselectEdit->setCurrentIndex(-1); | |
771 | this->fselectEdit->clear(); | |
772 | QString sql = "SELECT supplier,name,color,inventory FROM inventory_fermentables "; | |
773 | if (val) | |
774 | sql.append("WHERE inventory > 0 "); | |
775 | sql.append("ORDER BY supplier,name"); | |
776 | query.prepare(sql); | |
777 | query.exec(); | |
778 | query.first(); | |
779 | this->fselectEdit->addItem(""); // Start with empty value | |
780 | for (int i = 0; i < query.size(); i++) { | |
781 | this->fselectEdit->addItem(query.value(0).toString()+" - "+query.value(1).toString()+" ("+query.value(2).toString()+" EBC) "+ | |
782 | QString("%1 kg").arg(query.value(3).toDouble(), 4, 'f', 3, '0')); | |
783 | query.next(); | |
784 | } | |
785 | } | |
786 | ||
787 | ||
788 | void EditRecipe::ferment_added_changed(int val) | |
789 | { | |
790 | qDebug() << "ferment_added_changed()" << recipe->fermentables_row << val; | |
791 | ||
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
792 | recipe->fermentables[recipe->fermentables_row].added = val; |
301
fe6346211b5b
Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents:
284
diff
changeset
|
793 | QTableWidgetItem *item = new QTableWidgetItem(QCoreApplication::translate("FermentableAdded", g_fermentable_added[val])); |
127 | 794 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
795 | ui->fermentablesTable->setItem(recipe->fermentables_row, 5, item); | |
796 | ||
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
797 | famountEdit->setReadOnly(recipe->fermentables_use100 && recipe->fermentables.at(recipe->fermentables_row).added < 4); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
798 | pctEdit->setReadOnly(! (recipe->fermentables_use100 && recipe->fermentables.at(recipe->fermentables_row).added < 4)); |
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
|
799 | |
127 | 800 | double total = 0; |
801 | for (int i = 0; i < recipe->fermentables.size(); i++) | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
802 | if (recipe->fermentables.at(i).added < 4) // Only before bottle/kegging |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
803 | total += recipe->fermentables.at(i).amount; |
127 | 804 | for (int i = 0; i < recipe->fermentables.size(); i++) |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
805 | if (recipe->fermentables.at(i).added < 4) |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
806 | recipe->fermentables[i].percentage = recipe->fermentables.at(i).amount / total * 100; |
127 | 807 | |
808 | is_changed(); | |
809 | emit refreshAll(); | |
810 | } | |
811 | ||
812 | ||
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:
132
diff
changeset
|
813 | void EditRecipe::editFermentRow_clicked() |
127 | 814 | { |
815 | QSqlQuery query; | |
816 | ||
171
6cd2d808d863
Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents:
168
diff
changeset
|
817 | if (recipe->locked) |
6cd2d808d863
Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents:
168
diff
changeset
|
818 | return; |
6cd2d808d863
Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents:
168
diff
changeset
|
819 | |
127 | 820 | QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); |
821 | recipe->fermentables_row = pb->objectName().toInt(); | |
822 | qDebug() << "Edit fermentable row" << recipe->fermentables_row; | |
823 | Fermentables backup = recipe->fermentables.at(recipe->fermentables_row); | |
824 | ||
825 | QDialog* dialog = new QDialog(this); | |
826 | dialog->resize(738, 287); | |
827 | QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); | |
828 | buttonBox->setObjectName(QString::fromUtf8("buttonBox")); | |
829 | buttonBox->setGeometry(QRect(30, 240, 671, 32)); | |
830 | buttonBox->setLayoutDirection(Qt::LeftToRight); | |
831 | buttonBox->setOrientation(Qt::Horizontal); | |
832 | buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); | |
833 | buttonBox->setCenterButtons(true); | |
834 | QLabel *nameLabel = new QLabel(dialog); | |
835 | nameLabel->setObjectName(QString::fromUtf8("nameLabel")); | |
836 | nameLabel->setText(tr("Current ingredient:")); | |
837 | nameLabel->setGeometry(QRect(10, 10, 141, 20)); | |
838 | nameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
839 | QLabel *supplierLabel = new QLabel(dialog); | |
840 | supplierLabel->setObjectName(QString::fromUtf8("supplierLabel")); | |
841 | supplierLabel->setText(tr("Supplier:")); | |
842 | supplierLabel->setGeometry(QRect(10, 40, 141, 20)); | |
843 | supplierLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
844 | QLabel *amountLabel = new QLabel(dialog); | |
845 | amountLabel->setObjectName(QString::fromUtf8("amountLabel")); | |
846 | amountLabel->setText(tr("Amount in kg:")); | |
847 | amountLabel->setGeometry(QRect(10, 100, 141, 20)); | |
848 | amountLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
849 | QLabel *pctLabel = new QLabel(dialog); | |
850 | pctLabel->setObjectName(QString::fromUtf8("pctLabel")); | |
851 | pctLabel->setText(tr("Percentage in batch:")); | |
852 | pctLabel->setGeometry(QRect(10, 130, 141, 20)); | |
853 | pctLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
854 | QLabel *to100Label = new QLabel(dialog); | |
855 | to100Label->setObjectName(QString::fromUtf8("to100Label")); | |
856 | to100Label->setText(tr("Auto fill to 100%:")); | |
857 | to100Label->setGeometry(QRect(10, 160, 141, 20)); | |
858 | to100Label->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
859 | QLabel *addedLabel = new QLabel(dialog); | |
860 | addedLabel->setObjectName(QString::fromUtf8("addedLabel")); | |
861 | addedLabel->setText(tr("Use at:")); | |
862 | addedLabel->setGeometry(QRect(10, 190, 141, 20)); | |
863 | addedLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
864 | QLabel *selectLabel = new QLabel(dialog); | |
865 | selectLabel->setObjectName(QString::fromUtf8("selectLabel")); | |
866 | selectLabel->setText(tr("Select ingredient:")); | |
867 | selectLabel->setGeometry(QRect(10, 70, 141, 20)); | |
868 | selectLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
869 | QLabel *instockLabel = new QLabel(dialog); | |
870 | instockLabel->setObjectName(QString::fromUtf8("instockLabel")); | |
871 | instockLabel->setText(tr("In stock:")); | |
872 | instockLabel->setGeometry(QRect(525, 70, 121, 20)); | |
873 | instockLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
874 | QLabel *maxLabel = new QLabel(dialog); | |
875 | maxLabel->setObjectName(QString::fromUtf8("maxLabel")); | |
876 | maxLabel->setText(tr("Max in batch:")); | |
877 | maxLabel->setGeometry(QRect(420, 130, 121, 20)); | |
878 | maxLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
879 | ||
880 | fselectEdit = new QComboBox(dialog); | |
881 | fselectEdit->setObjectName(QString::fromUtf8("fselectEdit")); | |
882 | fselectEdit->setGeometry(QRect(160, 70, 371, 23)); | |
883 | ||
884 | fnameEdit = new QLineEdit(dialog); | |
885 | fnameEdit->setObjectName(QString::fromUtf8("fnameEdit")); | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
886 | fnameEdit->setText(recipe->fermentables.at(recipe->fermentables_row).name); |
127 | 887 | fnameEdit->setGeometry(QRect(160, 10, 511, 23)); |
888 | fnameEdit->setReadOnly(true); | |
889 | fsupplierEdit = new QLineEdit(dialog); | |
890 | fsupplierEdit->setObjectName(QString::fromUtf8("fsupplierEdit")); | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
891 | fsupplierEdit->setText(recipe->fermentables.at(recipe->fermentables_row).supplier); |
127 | 892 | fsupplierEdit->setGeometry(QRect(160, 40, 511, 23)); |
893 | fsupplierEdit->setReadOnly(true); | |
894 | famountEdit = new QDoubleSpinBox(dialog); | |
895 | famountEdit->setObjectName(QString::fromUtf8("famountEdit")); | |
896 | famountEdit->setGeometry(QRect(160, 100, 121, 24)); | |
897 | famountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
898 | famountEdit->setAccelerated(true); | |
899 | famountEdit->setDecimals(3); | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
900 | famountEdit->setReadOnly(recipe->fermentables_use100 && recipe->fermentables.at(recipe->fermentables_row).added < 4); |
127 | 901 | famountEdit->setMaximum(100000.0); |
902 | famountEdit->setSingleStep(0.0010); | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
903 | famountEdit->setValue(recipe->fermentables.at(recipe->fermentables_row).amount); |
127 | 904 | |
905 | pctEdit = new QDoubleSpinBox(dialog); | |
906 | pctEdit->setObjectName(QString::fromUtf8("pctEdit")); | |
907 | pctEdit->setGeometry(QRect(160, 130, 121, 24)); | |
908 | pctEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
909 | pctEdit->setAccelerated(true); | |
910 | pctEdit->setDecimals(1); | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
911 | if (recipe->fermentables_use100 && recipe->fermentables.at(recipe->fermentables_row).added < 4) { |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
912 | if (recipe->fermentables.at(recipe->fermentables_row).adjust_to_total_100) |
127 | 913 | pctEdit->setReadOnly(true); |
914 | else | |
915 | pctEdit->setReadOnly(false); | |
916 | } else { | |
917 | pctEdit->setReadOnly(true); | |
918 | } | |
919 | pctEdit->setMaximum(100.0); | |
920 | pctEdit->setSingleStep(0.1); | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
921 | pctEdit->setValue(recipe->fermentables.at(recipe->fermentables_row).percentage); |
127 | 922 | |
923 | faddedEdit = new QComboBox(dialog); | |
924 | faddedEdit->setObjectName(QString::fromUtf8("faddedEdit")); | |
925 | faddedEdit->setGeometry(QRect(160, 190, 161, 23)); | |
926 | faddedEdit->addItem(tr("Mash")); | |
927 | faddedEdit->addItem(tr("Boil")); | |
928 | faddedEdit->addItem(tr("Fermentation")); | |
929 | faddedEdit->addItem(tr("Lagering")); | |
930 | faddedEdit->addItem(tr("Bottle")); | |
931 | faddedEdit->addItem(tr("Kegs")); | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
932 | faddedEdit->setCurrentIndex(recipe->fermentables.at(recipe->fermentables_row).added); |
127 | 933 | |
934 | to100Edit = new QCheckBox(dialog); | |
935 | to100Edit->setObjectName(QString::fromUtf8("to100Edit")); | |
936 | to100Edit->setGeometry(QRect(160, 160, 85, 21)); | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
937 | to100Edit->setChecked(recipe->fermentables.at(recipe->fermentables_row).adjust_to_total_100); |
127 | 938 | |
939 | finstockEdit = new QCheckBox(dialog); | |
940 | finstockEdit->setObjectName(QString::fromUtf8("instockEdit")); | |
941 | finstockEdit->setGeometry(QRect(655, 70, 85, 21)); | |
942 | finstockEdit->setChecked(true); | |
943 | ||
944 | fmaxEdit = new QDoubleSpinBox(dialog); | |
945 | fmaxEdit->setObjectName(QString::fromUtf8("fmaxEdit")); | |
946 | fmaxEdit->setGeometry(QRect(550, 130, 121, 24)); | |
947 | fmaxEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
948 | fmaxEdit->setReadOnly(true); | |
949 | fmaxEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); | |
950 | fmaxEdit->setDecimals(1); | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
951 | fmaxEdit->setValue(recipe->fermentables.at(recipe->fermentables_row).max_in_batch); |
127 | 952 | |
953 | ferment_instock_changed(true); | |
954 | ||
955 | connect(fselectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::ferment_select_changed); | |
956 | connect(famountEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::ferment_amount_changed); | |
957 | connect(pctEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::ferment_pct_changed); | |
958 | connect(faddedEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::ferment_added_changed); | |
959 | connect(to100Edit, &QCheckBox::stateChanged, this, &EditRecipe::ferment_to100_changed); | |
960 | connect(finstockEdit, &QCheckBox::stateChanged, this, &EditRecipe::ferment_instock_changed); | |
961 | connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject())); | |
962 | connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); | |
963 | ||
964 | dialog->setModal(true); | |
965 | dialog->exec(); | |
966 | if (dialog->result() == QDialog::Rejected) { | |
967 | qDebug() << "reject and rollback"; | |
968 | recipe->fermentables[recipe->fermentables_row] = backup; | |
969 | /* | |
970 | * Recalculate the percentages | |
971 | */ | |
972 | double total = 0; | |
973 | for (int i = 0; i < recipe->fermentables.size(); i++) | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
974 | if (recipe->fermentables.at(i).added < 4) // Only before bottle/kegging |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
975 | total += recipe->fermentables.at(i).amount; |
127 | 976 | recipe->fermentables_use100 = false; |
977 | for (int i = 0; i < recipe->fermentables.size(); i++) { | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
978 | if (recipe->fermentables.at(i).adjust_to_total_100) |
127 | 979 | recipe->fermentables_use100 = true; |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
980 | if (recipe->fermentables.at(i).added < 4) { |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
981 | recipe->fermentables[i].percentage = recipe->fermentables.at(i).amount / total * 100; |
127 | 982 | } |
983 | } | |
984 | } | |
985 | ||
986 | disconnect(fselectEdit, nullptr, nullptr, nullptr); | |
987 | disconnect(famountEdit, nullptr, nullptr, nullptr); | |
988 | disconnect(pctEdit, nullptr, nullptr, nullptr); | |
989 | disconnect(faddedEdit, nullptr, nullptr, nullptr); | |
990 | disconnect(to100Edit, nullptr, nullptr, nullptr); | |
991 | disconnect(finstockEdit, nullptr, nullptr, nullptr); | |
992 | disconnect(buttonBox, nullptr, nullptr, nullptr); | |
993 | ||
994 | emit refreshAll(); | |
995 | } | |
996 | ||
997 |