Fri, 20 May 2022 22:06:06 +0200
Version 0.2.1. Updated translations.
127 | 1 | /** |
2 | * EditRecipe.cpp is part of bmsapp. | |
3 | * | |
4 | * Tab 3, hops | |
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::hop_sort_test(const Hops &D1, const Hops &D2) | |
23 | { | |
24 | if (D1.h_useat > D2.h_useat) | |
25 | return false; | |
26 | if (D1.h_useat < D2.h_useat) | |
27 | return true; | |
28 | /* Same useat moments, test time. */ | |
29 | if (D1.h_time < D2.h_time) | |
30 | return false; | |
31 | if (D1.h_time > D2.h_time) | |
32 | return true; | |
33 | /* Finally consider the amounts */ | |
34 | return (D1.h_amount > D2.h_amount); | |
35 | } | |
36 | ||
37 | ||
38 | void EditRecipe::refreshHops() | |
39 | { | |
40 | QString w; | |
41 | QWidget* pWidget; | |
42 | QHBoxLayout* pLayout; | |
43 | QTableWidgetItem *item; | |
44 | ||
45 | qDebug() << "refreshHops" << recipe->hops.size(); | |
46 | std::sort(recipe->hops.begin(), recipe->hops.end(), hop_sort_test); | |
47 | ||
48 | const QStringList labels({tr("Origin"), tr("Hop"), tr("Type"), tr("Form"), tr("Alpha"), tr("Use at"), tr("Time"), | |
49 | tr("IBU"), tr("Amount"), tr("Delete"), tr("Edit") }); | |
50 | ||
51 | ui->hopsTable->setColumnCount(11); | |
52 | ui->hopsTable->setColumnWidth(0, 150); /* Origin */ | |
53 | ui->hopsTable->setColumnWidth(1, 225); /* Hop */ | |
131
0115b97e8c39
Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.
Michiel Broek <mbroek@mbse.eu>
parents:
129
diff
changeset
|
54 | ui->hopsTable->setColumnWidth(2, 84); /* Type */ |
0115b97e8c39
Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.
Michiel Broek <mbroek@mbse.eu>
parents:
129
diff
changeset
|
55 | ui->hopsTable->setColumnWidth(3, 84); /* Form */ |
127 | 56 | ui->hopsTable->setColumnWidth(4, 75); /* Alpha% */ |
57 | ui->hopsTable->setColumnWidth(5, 75); /* Added */ | |
58 | ui->hopsTable->setColumnWidth(6, 75); /* Time */ | |
59 | ui->hopsTable->setColumnWidth(7, 60); /* IBU */ | |
131
0115b97e8c39
Added global variables, C++ lovers will hate that. Added global acid data. Fixed several load and save errors in the json arrays in the recipe record. Added first part of the miscs table. The first part of the water tab has values.
Michiel Broek <mbroek@mbse.eu>
parents:
129
diff
changeset
|
60 | ui->hopsTable->setColumnWidth(8, 90); /* Amount */ |
127 | 61 | ui->hopsTable->setColumnWidth(9, 80); /* Delete */ |
62 | ui->hopsTable->setColumnWidth(10, 80); /* Edit */ | |
63 | ui->hopsTable->setHorizontalHeaderLabels(labels); | |
64 | ui->hopsTable->verticalHeader()->hide(); | |
65 | ui->hopsTable->setRowCount(recipe->hops.size()); | |
66 | ||
67 | for (int i = 0; i < recipe->hops.size(); i++) { | |
68 | ||
69 | ui->hopsTable->setItem(i, 0, new QTableWidgetItem(recipe->hops.at(i).h_origin)); | |
70 | ui->hopsTable->setItem(i, 1, new QTableWidgetItem(recipe->hops.at(i).h_name)); | |
71 | ||
154
1af9f7b7f317
Moved QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents:
152
diff
changeset
|
72 | item = new QTableWidgetItem(hop_types[recipe->hops.at(i).h_type]); |
127 | 73 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
74 | ui->hopsTable->setItem(i, 2, item); | |
75 | ||
154
1af9f7b7f317
Moved QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents:
152
diff
changeset
|
76 | item = new QTableWidgetItem(hop_forms[recipe->hops.at(i).h_form]); |
127 | 77 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
78 | ui->hopsTable->setItem(i, 3, item); | |
79 | ||
80 | item = new QTableWidgetItem(QString("%1%").arg(recipe->hops.at(i).h_alpha, 2, 'f', 1, '0')); | |
81 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
82 | ui->hopsTable->setItem(i, 4, item); | |
83 | ||
154
1af9f7b7f317
Moved QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents:
152
diff
changeset
|
84 | item = new QTableWidgetItem(hop_useat[recipe->hops.at(i).h_useat]); |
127 | 85 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
86 | ui->hopsTable->setItem(i, 5, item); | |
87 | ||
88 | if (recipe->hops.at(i).h_useat == 2 || recipe->hops.at(i).h_useat == 4) { // Boil or whirlpool | |
89 | item = new QTableWidgetItem(QString("%1 min.").arg(recipe->hops.at(i).h_time, 1, 'f', 0, '0')); | |
90 | } else if (recipe->hops.at(i).h_useat == 5) { // Dry-hop | |
91 | item = new QTableWidgetItem(QString("%1 days.").arg(recipe->hops.at(i).h_time / 1440, 1, 'f', 0, '0')); | |
92 | } else { | |
93 | item = new QTableWidgetItem(QString("")); | |
94 | } | |
95 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
96 | ui->hopsTable->setItem(i, 6, item); | |
97 | ||
98 | double ibu = Utils::toIBU(recipe->hops.at(i).h_useat, recipe->hops.at(i).h_form, recipe->preboil_sg, recipe->batch_size, recipe->hops.at(i).h_amount, | |
208
615afedbcd25
Fixed 0 IBU for First Wort Hop or Mashhop is used.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
99 | recipe->hops.at(i).h_time, recipe->hops.at(i).h_alpha, recipe->ibu_method, 0, recipe->hops.at(i).h_time, |
615afedbcd25
Fixed 0 IBU for First Wort Hop or Mashhop is used.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
100 | 0, recipe->boil_time); |
127 | 101 | item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); |
102 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
103 | ui->hopsTable->setItem(i, 7, item); | |
104 | ||
105 | if (recipe->hops.at(i).h_amount < 1.0) { | |
106 | item = new QTableWidgetItem(QString("%1 gr").arg(recipe->hops.at(i).h_amount * 1000.0, 2, 'f', 1, '0')); | |
107 | } else { | |
108 | item = new QTableWidgetItem(QString("%1 kg").arg(recipe->hops.at(i).h_amount, 4, 'f', 3, '0')); | |
109 | } | |
110 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
111 | ui->hopsTable->setItem(i, 8, item); | |
112 | ||
113 | /* Add the Delete row button */ | |
114 | pWidget = new QWidget(); | |
115 | QPushButton* btn_dele = new QPushButton(); | |
116 | btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */ | |
117 | btn_dele->setText(tr("Delete")); | |
139
f947c6988e91
Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
118 | connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteHopRow_clicked())); |
127 | 119 | pLayout = new QHBoxLayout(pWidget); |
120 | pLayout->addWidget(btn_dele); | |
121 | pLayout->setContentsMargins(5, 0, 5, 0); | |
122 | pWidget->setLayout(pLayout); | |
123 | ui->hopsTable->setCellWidget(i, 9, pWidget); | |
124 | ||
125 | pWidget = new QWidget(); | |
126 | QPushButton* btn_edit = new QPushButton(); | |
127 | btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */ | |
128 | btn_edit->setText(tr("Edit")); | |
139
f947c6988e91
Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
129 | connect(btn_edit, SIGNAL(clicked()), this, SLOT(editHopRow_clicked())); |
127 | 130 | pLayout = new QHBoxLayout(pWidget); |
131 | pLayout->addWidget(btn_edit); | |
132 | pLayout->setContentsMargins(5, 0, 5, 0); | |
133 | pWidget->setLayout(pLayout); | |
134 | ui->hopsTable->setCellWidget(i, 10, pWidget); | |
135 | } | |
136 | } | |
137 | ||
138 | ||
139
f947c6988e91
Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
139 | void EditRecipe::hop_Flavour_valueChanged(int value) |
127 | 140 | { |
141 | if (value < 20) { | |
142 | ui->hop_tasteShow->setStyleSheet(bar_20); | |
143 | ui->hop_tasteShow->setFormat(tr("Very low")); | |
144 | } else if (value < 40) { | |
145 | ui->hop_tasteShow->setStyleSheet(bar_40); | |
146 | ui->hop_tasteShow->setFormat(tr("Low")); | |
147 | } else if (value < 60) { | |
148 | ui->hop_tasteShow->setStyleSheet(bar_60); | |
149 | ui->hop_tasteShow->setFormat(tr("Moderate")); | |
150 | } else if (value < 80) { | |
151 | ui->hop_tasteShow->setStyleSheet(bar_80); | |
152 | ui->hop_tasteShow->setFormat(tr("High")); | |
153 | } else { | |
154 | ui->hop_tasteShow->setStyleSheet(bar_100); | |
155 | ui->hop_tasteShow->setFormat(tr("Very high")); | |
156 | } | |
157 | } | |
158 | ||
159 | ||
139
f947c6988e91
Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
160 | void EditRecipe::hop_Aroma_valueChanged(int value) |
127 | 161 | { |
162 | if (value < 20) { | |
163 | ui->hop_aromaShow->setStyleSheet(bar_20); | |
164 | ui->hop_aromaShow->setFormat(tr("Very low")); | |
165 | } else if (value < 40) { | |
166 | ui->hop_aromaShow->setStyleSheet(bar_40); | |
167 | ui->hop_aromaShow->setFormat(tr("Low")); | |
168 | } else if (value < 60) { | |
169 | ui->hop_aromaShow->setStyleSheet(bar_60); | |
170 | ui->hop_aromaShow->setFormat(tr("Moderate")); | |
171 | } else if (value < 80) { | |
172 | ui->hop_aromaShow->setStyleSheet(bar_80); | |
173 | ui->hop_aromaShow->setFormat(tr("High")); | |
174 | } else { | |
175 | ui->hop_aromaShow->setStyleSheet(bar_100); | |
176 | ui->hop_aromaShow->setFormat(tr("Very high")); | |
177 | } | |
178 | } | |
179 | ||
180 | ||
181 | void EditRecipe::calcIBUs() | |
182 | { | |
183 | double hop_flavour = 0, hop_aroma = 0, ibus = 0; | |
184 | ||
185 | for (int i = 0; i < recipe->hops.size(); i++) { | |
186 | ||
187 | ibus += Utils::toIBU(recipe->hops.at(i).h_useat, recipe->hops.at(i).h_form, recipe->preboil_sg, recipe->batch_size, recipe->hops.at(i).h_amount, | |
208
615afedbcd25
Fixed 0 IBU for First Wort Hop or Mashhop is used.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
188 | recipe->hops.at(i).h_time, recipe->hops.at(i).h_alpha, recipe->ibu_method, 0, recipe->hops.at(i).h_time, |
615afedbcd25
Fixed 0 IBU for First Wort Hop or Mashhop is used.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
189 | 0, recipe->boil_time); |
127 | 190 | hop_flavour += Utils::hopFlavourContribution(recipe->hops.at(i).h_time, recipe->batch_size, recipe->hops.at(i).h_useat, recipe->hops.at(i).h_amount); |
191 | hop_aroma += Utils::hopAromaContribution(recipe->hops.at(i).h_time, recipe->batch_size, recipe->hops.at(i).h_useat, recipe->hops.at(i).h_amount); | |
192 | } | |
193 | ||
194 | hop_flavour = round(hop_flavour * 1000.0 / 5.0) / 10; | |
195 | hop_aroma = round(hop_aroma * 1000.0 / 6.0) / 10; | |
196 | if (hop_flavour > 100) | |
197 | hop_flavour = 100; | |
198 | if (hop_aroma > 100) | |
199 | hop_aroma = 100; | |
150
fd568cc1dd0e
Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
200 | qDebug() << "ibu" << recipe->est_ibu << ibus << "flavour" << hop_flavour << "aroma" << hop_aroma << "method" << recipe->ibu_method; |
127 | 201 | |
202 | recipe->est_ibu = ibus; | |
203 | ui->est_ibuEdit->setValue(recipe->est_ibu); | |
204 | ui->est_ibu2Edit->setValue(recipe->est_ibu); | |
151
b5b2483f3a3f
New recipe, calculate the boil_size. Lot's of ignoreChanges removeals and where needed QSignalBlocker is used. Bottle priming calculation added. In fermentables editor block and release to100 settings only in mash to fermentation steps, bottle and kegging are ignored. Update the IBU slider after hop changes. Set the mash name when another mash profile is selected. Don't backup initial infuse amount if there was no mash table. A small cosmetic layout change on the mash tab.
Michiel Broek <mbroek@mbse.eu>
parents:
150
diff
changeset
|
205 | ui->est_ibuShow->setValue(recipe->est_ibu); |
127 | 206 | ui->hop_tasteShow->setValue(hop_flavour); |
207 | ui->hop_aromaShow->setValue(hop_aroma); | |
208 | } | |
209 | ||
210 | ||
139
f947c6988e91
Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
211 | void EditRecipe::addHopRow_clicked() |
127 | 212 | { |
213 | Hops newh; | |
214 | ||
215 | qDebug() << "Add hop row"; | |
216 | ||
217 | for (int i = 0; i < recipe->hops.size(); i++) { | |
218 | if (recipe->hops.at(i).h_amount == 0 && recipe->hops.at(i).h_alpha == 0) | |
219 | return; // Add only one at a time. | |
220 | } | |
221 | ||
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
|
222 | newh.h_name = "Select one"; |
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
|
223 | newh.h_origin = ""; |
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
|
224 | newh.h_amount = 0; |
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
|
225 | newh.h_cost = 0; |
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
|
226 | newh.h_type = 0; |
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
|
227 | newh.h_form = 0; |
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
|
228 | newh.h_useat = 2; |
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
|
229 | newh.h_time = 0; |
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
|
230 | newh.h_alpha = 0; |
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
|
231 | newh.h_beta = 0; |
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
|
232 | newh.h_hsi = 0; |
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
|
233 | newh.h_humulene = 0; |
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
|
234 | newh.h_caryophyllene = 0; |
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
|
235 | newh.h_cohumulone = 0; |
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
|
236 | newh.h_myrcene = 0; |
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
|
237 | newh.h_total_oil = 0; |
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
|
238 | |
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
|
239 | recipe->hops.append(newh); |
127 | 240 | emit refreshAll(); |
241 | } | |
242 | ||
243 | ||
139
f947c6988e91
Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
244 | void EditRecipe::deleteHopRow_clicked() |
127 | 245 | { |
171
6cd2d808d863
Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents:
164
diff
changeset
|
246 | if (recipe->locked || recipe->hops.size() < 1) |
6cd2d808d863
Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents:
164
diff
changeset
|
247 | return; |
6cd2d808d863
Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents:
164
diff
changeset
|
248 | |
127 | 249 | QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); |
250 | int row = pb->objectName().toInt(); | |
251 | qDebug() << "Delete hop row" << row << recipe->hops.size(); | |
252 | ||
253 | int rc = QMessageBox::warning(this, tr("Delete hop"), tr("Delete %1").arg(recipe->hops.at(row).h_name), | |
254 | QMessageBox::Yes | QMessageBox::No, QMessageBox::No); | |
255 | if (rc == QMessageBox::No) | |
256 | return; | |
257 | ||
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
|
258 | recipe->hops.removeAt(row); |
a9c19eaab018
Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
127
diff
changeset
|
259 | is_changed(); |
a9c19eaab018
Blocked hop table edit. Implemented add and delete hop rows. Started the ui of the water tab.
Michiel Broek <mbroek@mbse.eu>
parents:
127
diff
changeset
|
260 | emit refreshAll(); |
127 | 261 | } |
262 | ||
263 | ||
264 | void EditRecipe::hop_amount_changed(double val) | |
265 | { | |
266 | QTableWidgetItem *item; | |
267 | ||
268 | qDebug() << "hop_amount_changed()" << recipe->hops_row << val; | |
269 | ||
270 | recipe->hops[recipe->hops_row].h_amount = val / 1000.0; | |
271 | item = new QTableWidgetItem(QString("%1 gr").arg(val, 2, 'f', 1, '0')); | |
272 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
273 | ui->hopsTable->setItem(recipe->hops_row, 8, item); | |
274 | ||
275 | double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).h_useat, recipe->hops.at(recipe->hops_row).h_form, recipe->preboil_sg, | |
276 | recipe->batch_size, recipe->hops.at(recipe->hops_row).h_amount, recipe->hops.at(recipe->hops_row).h_time, | |
208
615afedbcd25
Fixed 0 IBU for First Wort Hop or Mashhop is used.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
277 | recipe->hops.at(recipe->hops_row).h_alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).h_time, |
615afedbcd25
Fixed 0 IBU for First Wort Hop or Mashhop is used.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
278 | 0, recipe->boil_time); |
127 | 279 | |
280 | ibuEdit->setValue(ibu); | |
281 | item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); | |
282 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
283 | ui->hopsTable->setItem(recipe->hops_row, 7, item); | |
284 | ||
285 | calcIBUs(); | |
286 | is_changed(); | |
287 | } | |
288 | ||
289 | ||
290 | void EditRecipe::hop_time_changed(int val) | |
291 | { | |
292 | QTableWidgetItem *item; | |
293 | ||
294 | qDebug() << "hop_time_changed()" << recipe->hops_row << val; | |
295 | ||
296 | if (recipe->hops.at(recipe->hops_row).h_useat == 2 || recipe->hops.at(recipe->hops_row).h_useat == 4) { // Boil or whirlpool | |
297 | item = new QTableWidgetItem(QString("%1 min.").arg(val, 1, 'f', 0, '0')); | |
164 | 298 | recipe->hops[recipe->hops_row].h_time = val; |
127 | 299 | } else if (recipe->hops.at(recipe->hops_row).h_useat == 5) { // Dry-hop |
164 | 300 | item = new QTableWidgetItem(QString("%1 days.").arg(val, 1, 'f', 0, '0')); |
301 | recipe->hops[recipe->hops_row].h_time = val * 1440; | |
127 | 302 | } else { |
303 | item = new QTableWidgetItem(QString("")); | |
164 | 304 | recipe->hops[recipe->hops_row].h_time = val; |
127 | 305 | } |
306 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
307 | ui->hopsTable->setItem(recipe->hops_row, 6, item); | |
308 | ||
309 | double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).h_useat, recipe->hops.at(recipe->hops_row).h_form, recipe->preboil_sg, | |
310 | recipe->batch_size, recipe->hops.at(recipe->hops_row).h_amount, recipe->hops.at(recipe->hops_row).h_time, | |
208
615afedbcd25
Fixed 0 IBU for First Wort Hop or Mashhop is used.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
311 | recipe->hops.at(recipe->hops_row).h_alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).h_time, |
615afedbcd25
Fixed 0 IBU for First Wort Hop or Mashhop is used.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
312 | 0, recipe->boil_time); |
127 | 313 | |
314 | ibuEdit->setValue(ibu); | |
315 | item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); | |
316 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
317 | ui->hopsTable->setItem(recipe->hops_row, 7, item); | |
318 | ||
319 | calcIBUs(); | |
320 | is_changed(); | |
321 | } | |
322 | ||
323 | ||
324 | void EditRecipe::hop_select_changed(int val) | |
325 | { | |
326 | QSqlQuery query; | |
327 | bool instock = hinstockEdit->isChecked(); | |
328 | QString w; | |
329 | QTableWidgetItem *item; | |
330 | ||
331 | if (val < 1) | |
332 | return; | |
333 | ||
334 | qDebug() << "hop_select_changed()" << recipe->fermentables_row << val << instock; | |
335 | ||
336 | /* | |
337 | * Search the hop pointed by the index and instock flag. | |
338 | */ | |
339 | QString sql = "SELECT name,origin,alpha,beta,humulene,caryophyllene,cohumulone,myrcene,hsi,total_oil,type,form,cost FROM inventory_hops "; | |
340 | if (instock) | |
341 | sql.append("WHERE inventory > 0 "); | |
342 | sql.append("ORDER BY origin,name"); | |
343 | query.prepare(sql); | |
344 | query.exec(); | |
345 | query.first(); | |
346 | for (int i = 0; i < (val - 1); i++) { | |
347 | query.next(); | |
348 | } | |
349 | qDebug() << "found" << query.value(1).toString() << query.value(0).toString(); | |
350 | ||
351 | /* | |
352 | * Replace the hop record contents | |
353 | */ | |
354 | recipe->hops[recipe->hops_row].h_name = query.value(0).toString(); | |
355 | recipe->hops[recipe->hops_row].h_origin = query.value(1).toString(); | |
356 | recipe->hops[recipe->hops_row].h_alpha = query.value(2).toDouble(); | |
357 | recipe->hops[recipe->hops_row].h_beta = query.value(3).toDouble(); | |
358 | recipe->hops[recipe->hops_row].h_humulene = query.value(4).toDouble(); | |
359 | recipe->hops[recipe->hops_row].h_caryophyllene = query.value(5).toDouble(); | |
360 | recipe->hops[recipe->hops_row].h_cohumulone = query.value(6).toDouble(); | |
361 | recipe->hops[recipe->hops_row].h_myrcene = query.value(7).toDouble(); | |
362 | recipe->hops[recipe->hops_row].h_hsi = query.value(8).toDouble(); | |
363 | recipe->hops[recipe->hops_row].h_total_oil = query.value(9).toDouble(); | |
364 | recipe->hops[recipe->hops_row].h_type = query.value(10).toInt(); | |
365 | recipe->hops[recipe->hops_row].h_form = query.value(11).toInt(); | |
366 | recipe->hops[recipe->hops_row].h_cost = query.value(12).toDouble(); | |
367 | ||
368 | /* | |
369 | * Update the visible fields | |
370 | */ | |
371 | hnameEdit->setText(recipe->hops.at(recipe->hops_row).h_name); | |
372 | horiginEdit->setText(recipe->hops.at(recipe->hops_row).h_origin); | |
373 | ||
374 | double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).h_useat, recipe->hops.at(recipe->hops_row).h_form, recipe->preboil_sg, | |
375 | recipe->batch_size, recipe->hops.at(recipe->hops_row).h_amount, recipe->hops.at(recipe->hops_row).h_time, | |
208
615afedbcd25
Fixed 0 IBU for First Wort Hop or Mashhop is used.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
376 | recipe->hops.at(recipe->hops_row).h_alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).h_time, |
615afedbcd25
Fixed 0 IBU for First Wort Hop or Mashhop is used.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
377 | 0, recipe->boil_time); |
127 | 378 | ibuEdit->setValue(ibu); |
379 | ||
380 | ui->hopsTable->setItem(recipe->hops_row, 0, new QTableWidgetItem(recipe->hops.at(recipe->hops_row).h_origin)); | |
381 | ui->hopsTable->setItem(recipe->hops_row, 1, new QTableWidgetItem(recipe->hops.at(recipe->hops_row).h_name)); | |
382 | ||
154
1af9f7b7f317
Moved QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents:
152
diff
changeset
|
383 | item = new QTableWidgetItem(hop_types[recipe->hops.at(recipe->hops_row).h_type]); |
127 | 384 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
385 | ui->hopsTable->setItem(recipe->hops_row, 2, item); | |
386 | ||
154
1af9f7b7f317
Moved QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents:
152
diff
changeset
|
387 | item = new QTableWidgetItem(hop_forms[recipe->hops.at(recipe->hops_row).h_form]); |
127 | 388 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
389 | ui->hopsTable->setItem(recipe->hops_row, 3, item); | |
390 | ||
391 | item = new QTableWidgetItem(QString("%1%").arg(recipe->hops.at(recipe->hops_row).h_alpha, 2, 'f', 1, '0')); | |
392 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
393 | ui->hopsTable->setItem(recipe->hops_row, 4, item); | |
394 | ||
395 | item = new QTableWidgetItem(QString("%1").arg(ibu, 2, 'f', 1, '0')); | |
396 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); | |
397 | ui->hopsTable->setItem(recipe->hops_row, 7, item); | |
398 | ||
399 | calcIBUs(); | |
400 | is_changed(); | |
401 | } | |
402 | ||
403 | ||
404 | void EditRecipe::hop_instock_changed(bool val) | |
405 | { | |
406 | QSqlQuery query; | |
407 | ||
408 | qDebug() << "hop_instock_changed()" << recipe->hops_row << val; | |
409 | ||
410 | this->hselectEdit->setCurrentIndex(-1); | |
411 | this->hselectEdit->clear(); | |
412 | QString sql = "SELECT origin,name,alpha,inventory FROM inventory_hops "; | |
413 | if (val) | |
414 | sql.append("WHERE inventory > 0 "); | |
415 | sql.append("ORDER BY origin,name"); | |
416 | query.prepare(sql); | |
417 | query.exec(); | |
418 | query.first(); | |
419 | this->hselectEdit->addItem(""); // Start with empty value | |
420 | for (int i = 0; i < query.size(); i++) { | |
421 | this->hselectEdit->addItem(query.value(0).toString()+" - "+query.value(1).toString()+" ("+query.value(2).toString()+"%) "+ | |
422 | QString("%1 gr").arg(query.value(3).toDouble() * 1000.0, 2, 'f', 1, '0')); | |
423 | query.next(); | |
424 | } | |
425 | } | |
426 | ||
427 | ||
428 | void EditRecipe::hop_useat_changed(int val) | |
429 | { | |
430 | qDebug() << "hop_useat_changed()" << recipe->hops_row << val; | |
431 | ||
432 | recipe->hops[recipe->hops_row].h_useat = val; | |
154
1af9f7b7f317
Moved QStringList arrays to global.
Michiel Broek <mbroek@mbse.eu>
parents:
152
diff
changeset
|
433 | QTableWidgetItem *item = new QTableWidgetItem(hop_useat[val]); |
127 | 434 | item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter); |
435 | ui->hopsTable->setItem(recipe->hops_row, 5, item); | |
436 | ||
437 | if (val == 2 || val == 4) { // Boil or whirlpool | |
438 | htimeLabel->setText(tr("Time in minutes:")); | |
439 | htimeEdit->setValue(recipe->hops.at(recipe->hops_row).h_time); | |
440 | htimeEdit->setReadOnly(false); | |
441 | } else if (val == 5) { // Dry-hop | |
442 | htimeLabel->setText(tr("Time in days:")); | |
443 | htimeEdit->setValue(recipe->hops.at(recipe->hops_row).h_time / 1440); | |
444 | htimeEdit->setReadOnly(false); | |
445 | } else { | |
446 | htimeLabel->setText(""); | |
447 | htimeEdit->setValue(0); | |
448 | htimeEdit->setReadOnly(true); | |
449 | } | |
450 | ||
451 | is_changed(); | |
452 | emit refreshAll(); | |
453 | } | |
454 | ||
455 | ||
139
f947c6988e91
Fixed complains about missing signals. Added add misc row, misc amount changed, misc time changed, misc select changed and misc instock changed. Silence false changed trigger.
Michiel Broek <mbroek@mbse.eu>
parents:
131
diff
changeset
|
456 | void EditRecipe::editHopRow_clicked() |
127 | 457 | { |
458 | QSqlQuery query; | |
459 | ||
171
6cd2d808d863
Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents:
164
diff
changeset
|
460 | if (recipe->locked) |
6cd2d808d863
Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents:
164
diff
changeset
|
461 | return; |
6cd2d808d863
Implemented recipe lock setting.
Michiel Broek <mbroek@mbse.eu>
parents:
164
diff
changeset
|
462 | |
127 | 463 | QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender()); |
464 | recipe->hops_row = pb->objectName().toInt(); | |
465 | qDebug() << "Edit hop row" << recipe->hops_row; | |
466 | Hops backup = recipe->hops.at(recipe->hops_row); | |
467 | ||
468 | QDialog* dialog = new QDialog(this); | |
469 | dialog->resize(738, 260); | |
470 | QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); | |
471 | buttonBox->setObjectName(QString::fromUtf8("buttonBox")); | |
472 | buttonBox->setGeometry(QRect(30, 210, 671, 32)); | |
473 | buttonBox->setLayoutDirection(Qt::LeftToRight); | |
474 | buttonBox->setOrientation(Qt::Horizontal); | |
475 | buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok); | |
476 | buttonBox->setCenterButtons(true); | |
477 | QLabel *nameLabel = new QLabel(dialog); | |
478 | nameLabel->setObjectName(QString::fromUtf8("nameLabel")); | |
479 | nameLabel->setText(tr("Current hop:")); | |
480 | nameLabel->setGeometry(QRect(10, 10, 141, 20)); | |
481 | nameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
482 | QLabel *originLabel = new QLabel(dialog); | |
483 | originLabel->setObjectName(QString::fromUtf8("originLabel")); | |
484 | originLabel->setText(tr("Origin:")); | |
485 | originLabel->setGeometry(QRect(10, 40, 141, 20)); | |
486 | originLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
487 | QLabel *amountLabel = new QLabel(dialog); | |
488 | amountLabel->setObjectName(QString::fromUtf8("amountLabel")); | |
489 | amountLabel->setText(tr("Amount in gr:")); | |
490 | amountLabel->setGeometry(QRect(10, 100, 141, 20)); | |
491 | amountLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
492 | htimeLabel = new QLabel(dialog); | |
493 | htimeLabel->setObjectName(QString::fromUtf8("htimeLabel")); | |
494 | if (recipe->hops.at(recipe->hops_row).h_useat == 5) // Dry-hop | |
495 | htimeLabel->setText(tr("Time in days:")); | |
496 | else if (recipe->hops.at(recipe->hops_row).h_useat == 2 || recipe->hops.at(recipe->hops_row).h_useat == 4) // Boil or whirlpool | |
497 | htimeLabel->setText(tr("Time in minutes:")); | |
498 | else | |
499 | htimeLabel->setText(""); | |
500 | ||
501 | htimeLabel->setGeometry(QRect(10, 130, 141, 20)); | |
502 | htimeLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
503 | QLabel *useatLabel = new QLabel(dialog); | |
504 | useatLabel->setObjectName(QString::fromUtf8("useatLabel")); | |
505 | useatLabel->setText(tr("Use at:")); | |
506 | useatLabel->setGeometry(QRect(10, 160, 141, 20)); | |
507 | useatLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
508 | QLabel *selectLabel = new QLabel(dialog); | |
509 | selectLabel->setObjectName(QString::fromUtf8("selectLabel")); | |
510 | selectLabel->setText(tr("Select hop:")); | |
511 | selectLabel->setGeometry(QRect(10, 70, 141, 20)); | |
512 | selectLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
513 | QLabel *instockLabel = new QLabel(dialog); | |
514 | instockLabel->setObjectName(QString::fromUtf8("instockLabel")); | |
515 | instockLabel->setText(tr("In stock:")); | |
516 | instockLabel->setGeometry(QRect(525, 70, 121, 20)); | |
517 | instockLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
518 | QLabel *ibuLabel = new QLabel(dialog); | |
519 | ibuLabel->setObjectName(QString::fromUtf8("maxLabel")); | |
520 | ibuLabel->setText(tr("Bitterness IBU:")); | |
521 | ibuLabel->setGeometry(QRect(420, 130, 121, 20)); | |
522 | ibuLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
523 | ||
524 | hselectEdit = new QComboBox(dialog); | |
525 | hselectEdit->setObjectName(QString::fromUtf8("selectEdit")); | |
526 | hselectEdit->setGeometry(QRect(160, 70, 371, 23)); | |
527 | ||
528 | hnameEdit = new QLineEdit(dialog); | |
529 | hnameEdit->setObjectName(QString::fromUtf8("hnameEdit")); | |
530 | hnameEdit->setText(recipe->hops.at(recipe->hops_row).h_name); | |
531 | hnameEdit->setGeometry(QRect(160, 10, 511, 23)); | |
532 | hnameEdit->setReadOnly(true); | |
533 | horiginEdit = new QLineEdit(dialog); | |
534 | horiginEdit->setObjectName(QString::fromUtf8("horiginEdit")); | |
535 | horiginEdit->setText(recipe->hops.at(recipe->hops_row).h_origin); | |
536 | horiginEdit->setGeometry(QRect(160, 40, 511, 23)); | |
537 | horiginEdit->setReadOnly(true); | |
538 | hamountEdit = new QDoubleSpinBox(dialog); | |
539 | hamountEdit->setObjectName(QString::fromUtf8("hamountEdit")); | |
540 | hamountEdit->setGeometry(QRect(160, 100, 121, 24)); | |
541 | hamountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
542 | hamountEdit->setAccelerated(true); | |
543 | hamountEdit->setDecimals(1); | |
544 | hamountEdit->setMaximum(1000000.0); | |
545 | hamountEdit->setSingleStep(0.5); | |
546 | hamountEdit->setValue(recipe->hops.at(recipe->hops_row).h_amount * 1000.0); | |
547 | htimeEdit = new QSpinBox(dialog); | |
548 | htimeEdit->setObjectName(QString::fromUtf8("htimeEdit")); | |
549 | htimeEdit->setGeometry(QRect(160, 130, 121, 24)); | |
550 | htimeEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
551 | htimeEdit->setAccelerated(true); | |
552 | htimeEdit->setMaximum(10000.0); | |
553 | if (recipe->hops.at(recipe->hops_row).h_useat == 2 || recipe->hops.at(recipe->hops_row).h_useat == 4) { // Boil or whirlpool | |
554 | htimeEdit->setValue(recipe->hops.at(recipe->hops_row).h_time); | |
555 | htimeEdit->setReadOnly(false); | |
556 | } else if (recipe->hops.at(recipe->hops_row).h_useat == 5){ // Dry-hop | |
557 | htimeEdit->setValue(recipe->hops.at(recipe->hops_row).h_time / 1440); | |
558 | htimeEdit->setReadOnly(false); | |
559 | } else { | |
560 | htimeEdit->setReadOnly(true); | |
561 | } | |
562 | useatEdit = new QComboBox(dialog); | |
563 | useatEdit->setObjectName(QString::fromUtf8("useatEdit")); | |
564 | useatEdit->setGeometry(QRect(160, 160, 161, 23)); | |
565 | useatEdit->addItem(tr("Mash")); | |
566 | useatEdit->addItem(tr("First wort")); | |
567 | useatEdit->addItem(tr("Boil")); | |
568 | useatEdit->addItem(tr("Aroma")); | |
569 | useatEdit->addItem(tr("Whirlpool")); | |
570 | useatEdit->addItem(tr("Dry hop")); | |
571 | useatEdit->setCurrentIndex(recipe->hops.at(recipe->hops_row).h_useat); | |
572 | ||
573 | hinstockEdit = new QCheckBox(dialog); | |
574 | hinstockEdit->setObjectName(QString::fromUtf8("hinstockEdit")); | |
575 | hinstockEdit->setGeometry(QRect(655, 70, 85, 21)); | |
576 | hinstockEdit->setChecked(true); | |
577 | ||
578 | ibuEdit = new QDoubleSpinBox(dialog); | |
579 | ibuEdit->setObjectName(QString::fromUtf8("ibuEdit")); | |
580 | ibuEdit->setGeometry(QRect(550, 130, 121, 24)); | |
581 | ibuEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter); | |
582 | ibuEdit->setReadOnly(true); | |
583 | ibuEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); | |
584 | ibuEdit->setDecimals(1); | |
585 | double ibu = Utils::toIBU(recipe->hops.at(recipe->hops_row).h_useat, recipe->hops.at(recipe->hops_row).h_form, recipe->preboil_sg, | |
586 | recipe->batch_size, recipe->hops.at(recipe->hops_row).h_amount, recipe->hops.at(recipe->hops_row).h_time, | |
208
615afedbcd25
Fixed 0 IBU for First Wort Hop or Mashhop is used.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
587 | recipe->hops.at(recipe->hops_row).h_alpha, recipe->ibu_method, 0, recipe->hops.at(recipe->hops_row).h_time, |
615afedbcd25
Fixed 0 IBU for First Wort Hop or Mashhop is used.
Michiel Broek <mbroek@mbse.eu>
parents:
171
diff
changeset
|
588 | 0, recipe->boil_time); |
127 | 589 | ibuEdit->setValue(ibu); |
590 | ||
591 | hop_instock_changed(true); | |
592 | ||
593 | connect(hselectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::hop_select_changed); | |
594 | connect(hamountEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditRecipe::hop_amount_changed); | |
595 | connect(htimeEdit, QOverload<int>::of(&QSpinBox::valueChanged), this, &EditRecipe::hop_time_changed); | |
596 | connect(useatEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditRecipe::hop_useat_changed); | |
597 | connect(hinstockEdit, &QCheckBox::stateChanged, this, &EditRecipe::hop_instock_changed); | |
598 | connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject())); | |
599 | connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept())); | |
600 | ||
601 | dialog->setModal(true); | |
602 | dialog->exec(); | |
603 | if (dialog->result() == QDialog::Rejected) { | |
604 | qDebug() << "reject and rollback"; | |
605 | recipe->hops[recipe->hops_row] = backup; | |
606 | } else { | |
607 | /* Clear time if hop is not used for boil, whirlpool or dry-hop. */ | |
608 | if (! (recipe->hops.at(recipe->hops_row).h_useat == 2 || | |
609 | recipe->hops.at(recipe->hops_row).h_useat == 4 || | |
610 | recipe->hops.at(recipe->hops_row).h_useat == 5)) { | |
611 | if (recipe->hops.at(recipe->hops_row).h_time) { | |
612 | recipe->hops[recipe->hops_row].h_time = 0; | |
613 | is_changed(); | |
614 | } | |
615 | } | |
616 | } | |
617 | ||
618 | disconnect(hselectEdit, nullptr, nullptr, nullptr); | |
619 | disconnect(hamountEdit, nullptr, nullptr, nullptr); | |
620 | disconnect(htimeEdit, nullptr, nullptr, nullptr); | |
621 | disconnect(useatEdit, nullptr, nullptr, nullptr); | |
622 | disconnect(hinstockEdit, nullptr, nullptr, nullptr); | |
623 | disconnect(buttonBox, nullptr, nullptr, nullptr); | |
624 | ||
625 | emit refreshAll(); | |
626 | } | |
627 | ||
628 | ||
150
fd568cc1dd0e
Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
629 | void EditRecipe::adjustHops(double factor) |
fd568cc1dd0e
Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
630 | { |
fd568cc1dd0e
Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
631 | double amount; |
fd568cc1dd0e
Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
632 | |
fd568cc1dd0e
Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
633 | if (recipe->hops.size() == 0) |
fd568cc1dd0e
Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
634 | return; |
fd568cc1dd0e
Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
635 | |
fd568cc1dd0e
Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
636 | for (int i = 0; i < recipe->hops.size(); 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:
139
diff
changeset
|
637 | amount = recipe->hops.at(i).h_amount * factor; |
fd568cc1dd0e
Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
638 | recipe->hops[i].h_amount = amount; |
fd568cc1dd0e
Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
639 | } |
fd568cc1dd0e
Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
640 | } |
fd568cc1dd0e
Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
641 | |
fd568cc1dd0e
Implemented the last widgets on the first tab and added the needed functions for them such as scaling the recipe. This is the last part of the recipe editor, now ready for testing.
Michiel Broek <mbroek@mbse.eu>
parents:
139
diff
changeset
|
642 |