63 const QSignalBlocker blocker5(ui->bs_mgcl2Edit); |
63 const QSignalBlocker blocker5(ui->bs_mgcl2Edit); |
64 const QSignalBlocker blocker6(ui->bs_nahco3Edit); |
64 const QSignalBlocker blocker6(ui->bs_nahco3Edit); |
65 const QSignalBlocker blocker7(ui->bs_caco3Edit); |
65 const QSignalBlocker blocker7(ui->bs_caco3Edit); |
66 const QSignalBlocker blocker8(ui->mw_acidPick); |
66 const QSignalBlocker blocker8(ui->mw_acidPick); |
67 const QSignalBlocker blocker9(ui->mw_acidvolEdit); |
67 const QSignalBlocker blocker9(ui->mw_acidvolEdit); |
|
68 const QSignalBlocker blocker10(ui->ss_cacl2Edit); |
|
69 const QSignalBlocker blocker11(ui->ss_caso4Edit); |
|
70 const QSignalBlocker blocker12(ui->ss_mgso4Edit); |
|
71 const QSignalBlocker blocker13(ui->ss_naclEdit); |
|
72 const QSignalBlocker blocker14(ui->ss_mgcl2Edit); |
|
73 const QSignalBlocker blocker15(ui->sp_acidtypeEdit); |
|
74 const QSignalBlocker blocker16(ui->sp_acidvolEdit); |
68 |
75 |
69 const QStringList labels({tr("Ingredient"), tr("Type"), tr("Use at"), tr("Time"), tr("Amount"), tr("Stock"), tr("Delete"), tr("Edit") }); |
76 const QStringList labels({tr("Ingredient"), tr("Type"), tr("Use at"), tr("Time"), tr("Amount"), tr("Stock"), tr("Delete"), tr("Edit") }); |
70 |
77 |
71 ui->miscsTable->setColumnCount(8); |
78 ui->miscsTable->setColumnCount(8); |
72 ui->miscsTable->setColumnWidth(0, 250); /* Ingredient */ |
79 ui->miscsTable->setColumnWidth(0, 250); /* Ingredient */ |
177 } |
184 } |
178 |
185 |
179 /* |
186 /* |
180 * Update the water agents. |
187 * Update the water agents. |
181 */ |
188 */ |
182 if (product->miscs.at(i).type == MISC_TYPES_WATER_AGENT) { |
189 if (product->miscs.at(i).type == MISC_TYPES_WATER_AGENT && product->miscs.at(i).use_use == MISC_USES_MASH) { |
183 if (product->miscs.at(i).name == "CaCl2") { |
190 if (product->miscs.at(i).name == "CaCl2") { |
184 ui->bs_cacl2Edit->setValue(product->miscs.at(i).amount * 1000.0); |
191 ui->bs_cacl2Edit->setValue(product->miscs.at(i).amount * 1000.0); |
185 } else if (product->miscs.at(i).name == "CaSO4") { |
192 } else if (product->miscs.at(i).name == "CaSO4") { |
186 ui->bs_caso4Edit->setValue(product->miscs.at(i).amount * 1000.0); |
193 ui->bs_caso4Edit->setValue(product->miscs.at(i).amount * 1000.0); |
187 } else if (product->miscs.at(i).name == "MgSO4") { |
194 } else if (product->miscs.at(i).name == "MgSO4") { |
217 product->wa_acid_perc = my_acids.at(3).AcidPrc; |
224 product->wa_acid_perc = my_acids.at(3).AcidPrc; |
218 ui->mw_acidPick->setCurrentIndex(3); |
225 ui->mw_acidPick->setCurrentIndex(3); |
219 ui->mw_acidpercEdit->setValue(my_acids.at(3).AcidPrc); |
226 ui->mw_acidpercEdit->setValue(my_acids.at(3).AcidPrc); |
220 ui->mw_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0); |
227 ui->mw_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0); |
221 } |
228 } |
222 } |
229 } else if (product->miscs.at(i).type == MISC_TYPES_WATER_AGENT && product->miscs.at(i).use_use == MISC_USES_SPARGE) { |
|
230 if (product->miscs.at(i).name == "CaCl2") { |
|
231 ui->ss_cacl2Edit->setValue(product->miscs.at(i).amount * 1000.0); |
|
232 } else if (product->miscs.at(i).name == "CaSO4") { |
|
233 ui->ss_caso4Edit->setValue(product->miscs.at(i).amount * 1000.0); |
|
234 } else if (product->miscs.at(i).name == "MgSO4") { |
|
235 ui->ss_mgso4Edit->setValue(product->miscs.at(i).amount * 1000.0); |
|
236 } else if (product->miscs.at(i).name == "NaCl") { |
|
237 ui->ss_naclEdit->setValue(product->miscs.at(i).amount * 1000.0); |
|
238 } else if (product->miscs.at(i).name == "MgCl2") { |
|
239 ui->ss_mgcl2Edit->setValue(product->miscs.at(i).amount * 1000.0); |
|
240 } else if (product->miscs.at(i).name == "Melkzuur" || product->miscs.at(i).name == "Lactic") { |
|
241 product->sparge_acid_type = 0; |
|
242 product->sparge_acid_perc = my_acids.at(0).AcidPrc; |
|
243 ui->sp_acidtypeEdit->setCurrentIndex(0); |
|
244 ui->sp_acidpercEdit->setValue(my_acids.at(0).AcidPrc); |
|
245 ui->sp_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0); |
|
246 } else if (product->miscs.at(i).name == "Zoutzuur" || product->miscs.at(i).name == "Hydrochloric") { |
|
247 product->sparge_acid_type = 1; |
|
248 product->sparge_acid_perc = my_acids.at(1).AcidPrc; |
|
249 ui->sp_acidtypeEdit->setCurrentIndex(1); |
|
250 ui->sp_acidpercEdit->setValue(my_acids.at(1).AcidPrc); |
|
251 ui->sp_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0); |
|
252 } else if (product->miscs.at(i).name == "Fosforzuur" || product->miscs.at(i).name == "Phosphoric") { |
|
253 product->sparge_acid_type = 2; |
|
254 product->sparge_acid_perc = my_acids.at(2).AcidPrc; |
|
255 ui->sp_acidtypeEdit->setCurrentIndex(2); |
|
256 ui->sp_acidpercEdit->setValue(my_acids.at(2).AcidPrc); |
|
257 ui->sp_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0); |
|
258 } else if (product->miscs.at(i).name == "Zwavelzuur" || product->miscs.at(i).name == "Sulfuric") { |
|
259 product->sparge_acid_type = 3; |
|
260 product->sparge_acid_perc = my_acids.at(3).AcidPrc; |
|
261 ui->sp_acidtypeEdit->setCurrentIndex(3); |
|
262 ui->sp_acidpercEdit->setValue(my_acids.at(3).AcidPrc); |
|
263 ui->sp_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0); |
|
264 } |
|
265 } |
223 } |
266 } |
224 } |
267 } |
225 |
268 |
226 |
269 |
227 void EditProduct::calcMiscs() |
270 void EditProduct::calcMiscs() |
228 { |
271 { |
229 product->miscs_ok = true; |
272 product->miscs_ok = true; |
230 for (int i = 0; i < product->miscs.size(); i++) { |
273 for (int i = 0; i < product->miscs.size(); i++) { |
231 if ((((product->inventory_reduced <= PROD_STAGE_BREW) && (product->miscs.at(i).use_use <= MISC_USES_BOIL)) || // Starter, Mash, Boil |
274 if ((((product->inventory_reduced <= PROD_STAGE_BREW) && (product->miscs.at(i).use_use <= MISC_USES_BOIL)) || // Starter, Mash, Boil |
|
275 ((product->inventory_reduced <= PROD_STAGE_BREW) && (product->miscs.at(i).use_use == MISC_USES_SPARGE)) || |
232 ((product->inventory_reduced <= PROD_STAGE_PRIMARY) && (product->miscs.at(i).use_use == MISC_USES_PRIMARY)) || |
276 ((product->inventory_reduced <= PROD_STAGE_PRIMARY) && (product->miscs.at(i).use_use == MISC_USES_PRIMARY)) || |
233 ((product->inventory_reduced <= PROD_STAGE_TERTIARY) && (product->miscs.at(i).use_use == MISC_USES_SECONDARY)) || |
277 ((product->inventory_reduced <= PROD_STAGE_TERTIARY) && (product->miscs.at(i).use_use == MISC_USES_SECONDARY)) || |
234 ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->miscs.at(i).use_use == MISC_USES_BOTTLING))) && |
278 ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->miscs.at(i).use_use == MISC_USES_BOTTLING))) && |
235 (product->miscs.at(i).inventory < product->miscs.at(i).amount)) { |
279 (product->miscs.at(i).inventory < product->miscs.at(i).amount)) { |
236 product->miscs_ok = false; |
280 product->miscs_ok = false; |
240 |
284 |
241 |
285 |
242 /* |
286 /* |
243 * Manipulate the memory array and update the miscs table. |
287 * Manipulate the memory array and update the miscs table. |
244 */ |
288 */ |
245 void EditProduct::brewing_salt_sub(QString salt, double val) |
289 void EditProduct::brewing_salt_sub(QString salt, double val, int use) |
246 { |
290 { |
247 QTableWidgetItem *item; |
291 QTableWidgetItem *item; |
248 |
292 |
249 val = round(val * 100.0) / 100.0; |
293 val = round(val * 100.0) / 100.0; |
250 if (val == 0) { |
294 if (val == 0) { |
251 /* |
295 /* |
252 * Remove this salt if it is in the table. |
296 * Remove this salt if it is in the table. |
253 */ |
297 */ |
254 for (int i = 0; i < product->miscs.size(); i++) { |
298 for (int i = 0; i < product->miscs.size(); i++) { |
255 if (salt.contains(product->miscs.at(i).name)) { |
299 if (salt.contains(product->miscs.at(i).name) && product->miscs.at(i).use_use == use) { |
256 qDebug() << " brewing_salt_sub delete" << salt; |
300 qDebug() << " brewing_salt_sub delete" << salt << use; |
257 product->miscs.removeAt(i); |
301 product->miscs.removeAt(i); |
258 refreshMiscs(); |
302 refreshMiscs(); |
259 return; |
303 return; |
260 } |
304 } |
261 } |
305 } |
266 /* |
310 /* |
267 * First see if this salt is in the table. |
311 * First see if this salt is in the table. |
268 * If it is, update the amount. |
312 * If it is, update the amount. |
269 */ |
313 */ |
270 for (int i = 0; i < product->miscs.size(); i++) { |
314 for (int i = 0; i < product->miscs.size(); i++) { |
271 if (salt.contains(product->miscs.at(i).name)) { |
315 if (salt.contains(product->miscs.at(i).name) && product->miscs.at(i).use_use == use) { |
272 product->miscs[i].amount = val / 1000.0; |
316 product->miscs[i].amount = val / 1000.0; |
273 if (product->miscs.at(i).amount_is_weight) |
317 if (product->miscs.at(i).amount_is_weight) |
274 item = new QTableWidgetItem(QString("%1 gr").arg(val, 3, 'f', 2, '0')); |
318 item = new QTableWidgetItem(QString("%1 gr").arg(val, 3, 'f', 2, '0')); |
275 else |
319 else |
276 item = new QTableWidgetItem(QString("%1 ml").arg(val, 3, 'f', 2, '0')); |
320 item = new QTableWidgetItem(QString("%1 ml").arg(val, 3, 'f', 2, '0')); |
292 qDebug() << " found it, append"; |
336 qDebug() << " found it, append"; |
293 Miscs m; |
337 Miscs m; |
294 m.name = query.value(1).toString(); |
338 m.name = query.value(1).toString(); |
295 m.amount = val / 1000.0; |
339 m.amount = val / 1000.0; |
296 m.type = query.value(2).toInt(); |
340 m.type = query.value(2).toInt(); |
297 m.use_use = query.value(3).toInt(); |
341 m.use_use = use; |
298 m.time = query.value(4).toDouble(); |
342 m.time = query.value(4).toDouble(); |
299 m.amount_is_weight = query.value(5).toInt() ? true:false; |
343 m.amount_is_weight = query.value(5).toInt() ? true:false; |
300 m.cost = query.value(10).toDouble(); |
344 m.cost = query.value(10).toDouble(); |
301 m.inventory = query.value(9).toDouble(); |
345 m.inventory = query.value(9).toDouble(); |
302 product->miscs.append(m); |
346 product->miscs.append(m); |
303 refreshMiscs(); |
347 refreshMiscs(); |
304 return; |
348 return; |
305 } |
349 } |
306 } |
350 } |
307 |
351 |
308 qDebug() << "brewing_salt_sub, nothing done." << salt << val; |
352 qDebug() << "brewing_salt_sub, nothing done." << salt << val << use; |
309 } |
353 } |
310 |
354 |
311 |
355 |
312 /* |
356 /* |
313 * Edit brewing salt and recalculate. |
357 * Edit brewing salt and recalculate. |
314 */ |
358 */ |
315 void EditProduct::set_brewing_salt(QString salt, double val) |
359 void EditProduct::set_brewing_salt(QString salt, double val, int use) |
316 { |
360 { |
317 val = round(val * 100.0) / 100.0; |
361 val = round(val * 100.0) / 100.0; |
318 qDebug() << "set_brewing_salt" << salt << val; |
362 qDebug() << "set_brewing_salt" << salt << val << use; |
319 brewing_salt_sub(salt, val); |
363 brewing_salt_sub(salt, val, use); |
320 calcWater(); |
364 calcWater(); |
321 is_changed(); |
365 is_changed(); |
322 } |
366 } |
323 |
367 |
324 |
368 |
675 useatEdit->addItem(tr("Mash")); |
719 useatEdit->addItem(tr("Mash")); |
676 useatEdit->addItem(tr("Boil")); |
720 useatEdit->addItem(tr("Boil")); |
677 useatEdit->addItem(tr("Primary")); |
721 useatEdit->addItem(tr("Primary")); |
678 useatEdit->addItem(tr("Secondary")); |
722 useatEdit->addItem(tr("Secondary")); |
679 useatEdit->addItem(tr("Bottling")); |
723 useatEdit->addItem(tr("Bottling")); |
|
724 useatEdit->addItem(tr("Sparge")); |
680 useatEdit->setCurrentIndex(product->miscs.at(product->miscs_row).use_use); |
725 useatEdit->setCurrentIndex(product->miscs.at(product->miscs_row).use_use); |
681 |
726 |
682 minstockEdit = new QCheckBox(dialog); |
727 minstockEdit = new QCheckBox(dialog); |
683 minstockEdit->setObjectName(QString::fromUtf8("minstockEdit")); |
728 minstockEdit->setObjectName(QString::fromUtf8("minstockEdit")); |
684 minstockEdit->setGeometry(QRect(655, 40, 85, 21)); |
729 minstockEdit->setGeometry(QRect(655, 40, 85, 21)); |
735 const QSignalBlocker blocker4(ui->bs_naclEdit); |
780 const QSignalBlocker blocker4(ui->bs_naclEdit); |
736 const QSignalBlocker blocker5(ui->bs_mgcl2Edit); |
781 const QSignalBlocker blocker5(ui->bs_mgcl2Edit); |
737 const QSignalBlocker blocker6(ui->bs_nahco3Edit); |
782 const QSignalBlocker blocker6(ui->bs_nahco3Edit); |
738 const QSignalBlocker blocker7(ui->bs_caco3Edit); |
783 const QSignalBlocker blocker7(ui->bs_caco3Edit); |
739 const QSignalBlocker blocker9(ui->mw_acidvolEdit); |
784 const QSignalBlocker blocker9(ui->mw_acidvolEdit); |
|
785 const QSignalBlocker blocker10(ui->ss_cacl2Edit); |
|
786 const QSignalBlocker blocker11(ui->ss_caso4Edit); |
|
787 const QSignalBlocker blocker12(ui->ss_mgso4Edit); |
|
788 const QSignalBlocker blocker13(ui->ss_naclEdit); |
|
789 const QSignalBlocker blocker14(ui->ss_mgcl2Edit); |
740 |
790 |
741 for (int i = 0; i < product->miscs.size(); i++) { |
791 for (int i = 0; i < product->miscs.size(); i++) { |
742 amount = product->miscs.at(i).amount * factor; |
792 amount = product->miscs.at(i).amount * factor; |
743 product->miscs[i].amount = amount; |
793 product->miscs[i].amount = amount; |
744 |
794 |
745 /* |
795 /* |
746 * Update the water agents. |
796 * Update the water agents. |
747 */ |
797 */ |
748 if (product->miscs.at(i).type == MISC_TYPES_WATER_AGENT) { |
798 if (product->miscs.at(i).type == MISC_TYPES_WATER_AGENT && product->miscs.at(i).use_use == MISC_USES_MASH) { |
749 if (product->miscs.at(i).name == "CaCl2") { |
799 if (product->miscs.at(i).name == "CaCl2") { |
750 ui->bs_cacl2Edit->setValue(product->miscs.at(i).amount * 1000.0); |
800 ui->bs_cacl2Edit->setValue(product->miscs.at(i).amount * 1000.0); |
751 } else if (product->miscs.at(i).name == "CaSO4") { |
801 } else if (product->miscs.at(i).name == "CaSO4") { |
752 ui->bs_caso4Edit->setValue(product->miscs.at(i).amount * 1000.0); |
802 ui->bs_caso4Edit->setValue(product->miscs.at(i).amount * 1000.0); |
753 } else if (product->miscs.at(i).name == "MgSO4") { |
803 } else if (product->miscs.at(i).name == "MgSO4") { |
767 } else if (product->miscs.at(i).name == "Fosforzuur" || product->miscs.at(i).name == "Phosphoric") { |
817 } else if (product->miscs.at(i).name == "Fosforzuur" || product->miscs.at(i).name == "Phosphoric") { |
768 ui->mw_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0); |
818 ui->mw_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0); |
769 } else if (product->miscs.at(i).name == "Zwavelzuur" || product->miscs.at(i).name == "Sulfuric") { |
819 } else if (product->miscs.at(i).name == "Zwavelzuur" || product->miscs.at(i).name == "Sulfuric") { |
770 ui->mw_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0); |
820 ui->mw_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0); |
771 } |
821 } |
|
822 } else if (product->miscs.at(i).type == MISC_TYPES_WATER_AGENT && product->miscs.at(i).use_use == MISC_USES_SPARGE) { |
|
823 if (product->miscs.at(i).name == "CaCl2") { |
|
824 ui->ss_cacl2Edit->setValue(product->miscs.at(i).amount * 1000.0); |
|
825 } else if (product->miscs.at(i).name == "CaSO4") { |
|
826 ui->ss_caso4Edit->setValue(product->miscs.at(i).amount * 1000.0); |
|
827 } else if (product->miscs.at(i).name == "MgSO4") { |
|
828 ui->ss_mgso4Edit->setValue(product->miscs.at(i).amount * 1000.0); |
|
829 } else if (product->miscs.at(i).name == "NaCl") { |
|
830 ui->ss_naclEdit->setValue(product->miscs.at(i).amount * 1000.0); |
|
831 } else if (product->miscs.at(i).name == "MgCl2") { |
|
832 ui->ss_mgcl2Edit->setValue(product->miscs.at(i).amount * 1000.0); |
|
833 } else if (product->miscs.at(i).name == "Melkzuur" || product->miscs.at(i).name == "Lactic") { |
|
834 ui->sp_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0); |
|
835 } else if (product->miscs.at(i).name == "Zoutzuur" || product->miscs.at(i).name == "Hydrochloric") { |
|
836 ui->sp_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0); |
|
837 } else if (product->miscs.at(i).name == "Fosforzuur" || product->miscs.at(i).name == "Phosphoric") { |
|
838 ui->sp_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0); |
|
839 } else if (product->miscs.at(i).name == "Zwavelzuur" || product->miscs.at(i).name == "Sulfuric") { |
|
840 ui->sp_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0); |
|
841 } |
772 } |
842 } |
773 } |
843 } |
774 } |
844 } |
775 |
845 |
776 |
846 |