src/EditProductTab5.cpp

Thu, 18 Aug 2022 20:34:15 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 18 Aug 2022 20:34:15 +0200
changeset 401
583148eb6e01
parent 359
dfbb012c631c
child 435
6f84ab6125ad
permissions
-rw-r--r--

Init est_carb field for new products.

175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * EditProduct.cpp is part of bmsapp.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * tab 5, miscs.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 *
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * bmsapp is free software: you can redistribute it and/or modify
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 * the Free Software Foundation, either version 3 of the License, or
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * (at your option) any later version.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 *
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * bmsapp is distributed in the hope that it will be useful,
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * GNU General Public License for more details.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 *
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 * You should have received a copy of the GNU General Public License
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
18 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21 bool EditProduct::misc_sort_test(const Miscs &D1, const Miscs &D2)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 {
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
23 if (D1.use_use > D2.use_use)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 return false;
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
25 if (D1.use_use < D2.use_use)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26 return true;
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
27 if (D1.type > D2.type)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28 return false;
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
29 if (D1.type < D2.type)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 return true;
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
31 return (D1.amount > D2.amount);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34
305
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
35 bool EditProduct::block_misc(int stage, int use_use)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
36 {
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
37 if (stage > PROD_STAGE_TERTIARY && use_use < MISC_USES_BOTTLING)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
38 return true;
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
39 if (stage > PROD_STAGE_PRIMARY && use_use < MISC_USES_SECONDARY)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
40 return true;
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
41 if (stage > PROD_STAGE_BREW && use_use < MISC_USES_PRIMARY)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
42 return true;
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
43 if (stage > PROD_STAGE_WAIT && use_use < MISC_USES_MASH)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
44 return true;
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
45 return false;
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
46 }
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
47
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
48
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49 void EditProduct::refreshMiscs()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 QString w;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 QWidget* pWidget;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 QHBoxLayout* pLayout;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 qDebug() << "refreshMiscs" << product->miscs.size();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 std::sort(product->miscs.begin(), product->miscs.end(), misc_sort_test);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 const QSignalBlocker blocker1(ui->bs_cacl2Edit);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 const QSignalBlocker blocker2(ui->bs_caso4Edit);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 const QSignalBlocker blocker3(ui->bs_mgso4Edit);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 const QSignalBlocker blocker4(ui->bs_naclEdit);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 const QSignalBlocker blocker5(ui->bs_mgcl2Edit);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 const QSignalBlocker blocker6(ui->bs_nahco3Edit);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 const QSignalBlocker blocker7(ui->bs_caco3Edit);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 const QSignalBlocker blocker8(ui->mw_acidPick);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 const QSignalBlocker blocker9(ui->mw_acidvolEdit);
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
68 const QSignalBlocker blocker10(ui->ss_cacl2Edit);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
69 const QSignalBlocker blocker11(ui->ss_caso4Edit);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
70 const QSignalBlocker blocker12(ui->ss_mgso4Edit);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
71 const QSignalBlocker blocker13(ui->ss_naclEdit);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
72 const QSignalBlocker blocker14(ui->ss_mgcl2Edit);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
73 const QSignalBlocker blocker15(ui->sp_acidtypeEdit);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
74 const QSignalBlocker blocker16(ui->sp_acidvolEdit);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75
179
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
76 const QStringList labels({tr("Ingredient"), tr("Type"), tr("Use at"), tr("Time"), tr("Amount"), tr("Stock"), tr("Delete"), tr("Edit") });
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77
179
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
78 ui->miscsTable->setColumnCount(8);
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
79 ui->miscsTable->setColumnWidth(0, 250); /* Ingredient */
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
80 ui->miscsTable->setColumnWidth(1, 90); /* Type */
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
81 ui->miscsTable->setColumnWidth(2, 90); /* Added */
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 ui->miscsTable->setColumnWidth(3, 75); /* Time */
179
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
83 ui->miscsTable->setColumnWidth(4, 80); /* Amount */
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
84 ui->miscsTable->setColumnWidth(5, 80); /* Stock */
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
85 ui->miscsTable->setColumnWidth(6, 80); /* Delete */
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
86 ui->miscsTable->setColumnWidth(7, 80); /* Edit */
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 ui->miscsTable->setHorizontalHeaderLabels(labels);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 ui->miscsTable->verticalHeader()->hide();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 ui->miscsTable->setRowCount(product->miscs.size());
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 for (int i = 0; i < product->miscs.size(); i++) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
93 ui->miscsTable->setItem(i, 0, new QTableWidgetItem(product->miscs.at(i).name));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
95 item = new QTableWidgetItem(QCoreApplication::translate("MiscType", g_misc_types[product->miscs.at(i).type]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 ui->miscsTable->setItem(i, 1, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
99 item = new QTableWidgetItem(QCoreApplication::translate("MiscUse", g_misc_uses[product->miscs.at(i).use_use]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 ui->miscsTable->setItem(i, 2, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
103 if (product->miscs.at(i).use_use == MISC_USES_BOIL) {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
104 item = new QTableWidgetItem(QString("%1 min.").arg(product->miscs.at(i).time, 1, 'f', 0, '0'));
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
105 } else if (product->miscs.at(i).use_use == MISC_USES_PRIMARY || product->miscs.at(i).use_use == MISC_USES_SECONDARY) {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
106 item = new QTableWidgetItem(QString("%1 days.").arg(product->miscs.at(i).time / 1440, 1, 'f', 0, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 item = new QTableWidgetItem(QString(""));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111 ui->miscsTable->setItem(i, 3, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
113 if (product->miscs.at(i).amount_is_weight)
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
114 item = new QTableWidgetItem(QString("%1 gr").arg(product->miscs.at(i).amount * 1000.0, 3, 'f', 2, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 else
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
116 item = new QTableWidgetItem(QString("%1 ml").arg(product->miscs.at(i).amount * 1000.0, 3, 'f', 2, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 ui->miscsTable->setItem(i, 4, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119
305
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
120 if (block_misc(product->stage, product->miscs.at(i).use_use)) {
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
121 item = new QTableWidgetItem(QString(""));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
122 } else {
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
123 if (product->miscs.at(i).amount_is_weight)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
124 item = new QTableWidgetItem(QString("%1 gr").arg(product->miscs.at(i).inventory * 1000.0, 3, 'f', 2, '0'));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
125 else
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
126 item = new QTableWidgetItem(QString("%1 ml").arg(product->miscs.at(i).inventory * 1000.0, 3, 'f', 2, '0'));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
127 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
128 if (product->miscs.at(i).inventory < product->miscs.at(i).amount)
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
129 item->setForeground(QBrush(QColor(Qt::red)));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
130 }
179
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
131 ui->miscsTable->setItem(i, 5, item);
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
132
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
133 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
134 * Add the Delete and Edit row buttons.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
135 * Not for water agents, these are set on the water tab.
305
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
136 * And also not if the ingredient has been used.
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 */
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
138 if (product->miscs.at(i).type == MISC_TYPES_WATER_AGENT) {
260
42b88d85fefc Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.
Michiel Broek <mbroek@mbse.eu>
parents: 194
diff changeset
139 ui->miscsTable->removeCellWidget(i, 6); /* to remove the unneeded button */
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
140 item = new QTableWidgetItem("");
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
141 item->setToolTip(tr("Edit this from the water tab"));
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
142 ui->miscsTable->setItem(i, 6, item);
260
42b88d85fefc Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.
Michiel Broek <mbroek@mbse.eu>
parents: 194
diff changeset
143 ui->miscsTable->removeCellWidget(i, 7);
190
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
144 item = new QTableWidgetItem("");
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
145 item->setToolTip(tr("Edit this from the water tab"));
bb6c06910f0f Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents: 179
diff changeset
146 ui->miscsTable->setItem(i, 7, item);
305
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
147 } else if (block_misc(product->stage, product->miscs.at(i).use_use)) {
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
148 ui->miscsTable->removeCellWidget(i, 6); /* to remove the unneeded button */
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
149 item = new QTableWidgetItem("");
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
150 item->setToolTip(tr("Misc already used"));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
151 ui->miscsTable->setItem(i, 6, item);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
152 ui->miscsTable->removeCellWidget(i, 7);
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
153 item = new QTableWidgetItem("");
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
154 item->setToolTip(tr("Misc already used"));
35ce719998e1 Added reduce inventory for all process stages. Added block fermentable to block buttons and inventory when the fermentable has been reduced. Added block hop to block buttons and inventory when the fermentable has been reduced. Added block misc to block buttons and inventory when the fermentable has been reduced. Added block yeast to block buttons and inventory when the fermentable has been reduced.
Michiel Broek <mbroek@mbse.eu>
parents: 301
diff changeset
155 ui->miscsTable->setItem(i, 7, item);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
156 } else {
260
42b88d85fefc Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.
Michiel Broek <mbroek@mbse.eu>
parents: 194
diff changeset
157 if (ui->miscsTable->item(i, 6)) {
42b88d85fefc Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.
Michiel Broek <mbroek@mbse.eu>
parents: 194
diff changeset
158 ui->miscsTable->takeItem(i, 6); /* to remove the old tooltip */
42b88d85fefc Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.
Michiel Broek <mbroek@mbse.eu>
parents: 194
diff changeset
159 }
42b88d85fefc Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.
Michiel Broek <mbroek@mbse.eu>
parents: 194
diff changeset
160 if (ui->miscsTable->item(i, 7)) {
42b88d85fefc Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.
Michiel Broek <mbroek@mbse.eu>
parents: 194
diff changeset
161 ui->miscsTable->takeItem(i, 7);
42b88d85fefc Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.
Michiel Broek <mbroek@mbse.eu>
parents: 194
diff changeset
162 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
163 pWidget = new QWidget();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
164 QPushButton* btn_dele = new QPushButton();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
165 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
166 btn_dele->setText(tr("Delete"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
167 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteMiscRow_clicked()));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
168 pLayout = new QHBoxLayout(pWidget);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
169 pLayout->addWidget(btn_dele);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170 pLayout->setContentsMargins(5, 0, 5, 0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
171 pWidget->setLayout(pLayout);
179
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
172 ui->miscsTable->setCellWidget(i, 6, pWidget);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
173
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
174 pWidget = new QWidget();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
175 QPushButton* btn_edit = new QPushButton();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
176 btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
177 btn_edit->setText(tr("Edit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
178 connect(btn_edit, SIGNAL(clicked()), this, SLOT(editMiscRow_clicked()));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
179 pLayout = new QHBoxLayout(pWidget);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
180 pLayout->addWidget(btn_edit);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
181 pLayout->setContentsMargins(5, 0, 5, 0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 pWidget->setLayout(pLayout);
179
512f492358e3 Miscs updates the current inventory during recipe load. Yeasts updates the current inventory during recipe load and does a better job for the fields to upgrade.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
183 ui->miscsTable->setCellWidget(i, 7, pWidget);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
184 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
185
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
186 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
187 * Update the water agents.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188 */
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
189 if (product->miscs.at(i).type == MISC_TYPES_WATER_AGENT && product->miscs.at(i).use_use == MISC_USES_MASH) {
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
190 if (product->miscs.at(i).name == "CaCl2") {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
191 ui->bs_cacl2Edit->setValue(product->miscs.at(i).amount * 1000.0);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
192 } else if (product->miscs.at(i).name == "CaSO4") {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
193 ui->bs_caso4Edit->setValue(product->miscs.at(i).amount * 1000.0);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
194 } else if (product->miscs.at(i).name == "MgSO4") {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
195 ui->bs_mgso4Edit->setValue(product->miscs.at(i).amount * 1000.0);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
196 } else if (product->miscs.at(i).name == "NaCl") {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
197 ui->bs_naclEdit->setValue(product->miscs.at(i).amount * 1000.0);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
198 } else if (product->miscs.at(i).name == "MgCl2") {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
199 ui->bs_mgcl2Edit->setValue(product->miscs.at(i).amount * 1000.0);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
200 } else if (product->miscs.at(i).name == "NaHCO3") {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
201 ui->bs_nahco3Edit->setValue(product->miscs.at(i).amount * 1000.0);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
202 } else if (product->miscs.at(i).name == "CaCO3") {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
203 ui->bs_caco3Edit->setValue(product->miscs.at(i).amount * 1000.0);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
204 } else if (product->miscs.at(i).name == "Melkzuur" || product->miscs.at(i).name == "Lactic") {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
205 product->wa_acid_name = 0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
206 product->wa_acid_perc = my_acids.at(0).AcidPrc;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207 ui->mw_acidPick->setCurrentIndex(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
208 ui->mw_acidpercEdit->setValue(my_acids.at(0).AcidPrc);
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
209 ui->mw_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
210 } else if (product->miscs.at(i).name == "Zoutzuur" || product->miscs.at(i).name == "Hydrochloric") {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 product->wa_acid_name = 1;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 product->wa_acid_perc = my_acids.at(1).AcidPrc;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 ui->mw_acidPick->setCurrentIndex(1);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 ui->mw_acidpercEdit->setValue(my_acids.at(1).AcidPrc);
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
215 ui->mw_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
216 } else if (product->miscs.at(i).name == "Fosforzuur" || product->miscs.at(i).name == "Phosphoric") {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
217 product->wa_acid_name = 2;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
218 product->wa_acid_perc = my_acids.at(2).AcidPrc;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
219 ui->mw_acidPick->setCurrentIndex(2);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
220 ui->mw_acidpercEdit->setValue(my_acids.at(2).AcidPrc);
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
221 ui->mw_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
222 } else if (product->miscs.at(i).name == "Zwavelzuur" || product->miscs.at(i).name == "Sulfuric") {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
223 product->wa_acid_name = 3;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
224 product->wa_acid_perc = my_acids.at(3).AcidPrc;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
225 ui->mw_acidPick->setCurrentIndex(3);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
226 ui->mw_acidpercEdit->setValue(my_acids.at(3).AcidPrc);
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
227 ui->mw_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
228 }
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
229 } else if (product->miscs.at(i).type == MISC_TYPES_WATER_AGENT && product->miscs.at(i).use_use == MISC_USES_SPARGE) {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
230 if (product->miscs.at(i).name == "CaCl2") {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
231 ui->ss_cacl2Edit->setValue(product->miscs.at(i).amount * 1000.0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
232 } else if (product->miscs.at(i).name == "CaSO4") {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
233 ui->ss_caso4Edit->setValue(product->miscs.at(i).amount * 1000.0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
234 } else if (product->miscs.at(i).name == "MgSO4") {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
235 ui->ss_mgso4Edit->setValue(product->miscs.at(i).amount * 1000.0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
236 } else if (product->miscs.at(i).name == "NaCl") {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
237 ui->ss_naclEdit->setValue(product->miscs.at(i).amount * 1000.0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
238 } else if (product->miscs.at(i).name == "MgCl2") {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
239 ui->ss_mgcl2Edit->setValue(product->miscs.at(i).amount * 1000.0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
240 } else if (product->miscs.at(i).name == "Melkzuur" || product->miscs.at(i).name == "Lactic") {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
241 product->sparge_acid_type = 0;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
242 product->sparge_acid_perc = my_acids.at(0).AcidPrc;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
243 ui->sp_acidtypeEdit->setCurrentIndex(0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
244 ui->sp_acidpercEdit->setValue(my_acids.at(0).AcidPrc);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
245 ui->sp_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
246 } else if (product->miscs.at(i).name == "Zoutzuur" || product->miscs.at(i).name == "Hydrochloric") {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
247 product->sparge_acid_type = 1;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
248 product->sparge_acid_perc = my_acids.at(1).AcidPrc;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
249 ui->sp_acidtypeEdit->setCurrentIndex(1);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
250 ui->sp_acidpercEdit->setValue(my_acids.at(1).AcidPrc);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
251 ui->sp_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
252 } else if (product->miscs.at(i).name == "Fosforzuur" || product->miscs.at(i).name == "Phosphoric") {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
253 product->sparge_acid_type = 2;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
254 product->sparge_acid_perc = my_acids.at(2).AcidPrc;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
255 ui->sp_acidtypeEdit->setCurrentIndex(2);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
256 ui->sp_acidpercEdit->setValue(my_acids.at(2).AcidPrc);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
257 ui->sp_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
258 } else if (product->miscs.at(i).name == "Zwavelzuur" || product->miscs.at(i).name == "Sulfuric") {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
259 product->sparge_acid_type = 3;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
260 product->sparge_acid_perc = my_acids.at(3).AcidPrc;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
261 ui->sp_acidtypeEdit->setCurrentIndex(3);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
262 ui->sp_acidpercEdit->setValue(my_acids.at(3).AcidPrc);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
263 ui->sp_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
264 }
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
265 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
266 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
267 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
268
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
269
194
ea8cce5e7eb9 Added calcMiscs(). In miscs check supplies. Update inventory check when setting a new brewing salt. Use enum constants to make code more readable.
Michiel Broek <mbroek@mbse.eu>
parents: 190
diff changeset
270 void EditProduct::calcMiscs()
ea8cce5e7eb9 Added calcMiscs(). In miscs check supplies. Update inventory check when setting a new brewing salt. Use enum constants to make code more readable.
Michiel Broek <mbroek@mbse.eu>
parents: 190
diff changeset
271 {
ea8cce5e7eb9 Added calcMiscs(). In miscs check supplies. Update inventory check when setting a new brewing salt. Use enum constants to make code more readable.
Michiel Broek <mbroek@mbse.eu>
parents: 190
diff changeset
272 product->miscs_ok = true;
ea8cce5e7eb9 Added calcMiscs(). In miscs check supplies. Update inventory check when setting a new brewing salt. Use enum constants to make code more readable.
Michiel Broek <mbroek@mbse.eu>
parents: 190
diff changeset
273 for (int i = 0; i < product->miscs.size(); i++) {
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
274 if ((((product->inventory_reduced <= PROD_STAGE_BREW) && (product->miscs.at(i).use_use <= MISC_USES_BOIL)) || // Starter, Mash, Boil
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
275 ((product->inventory_reduced <= PROD_STAGE_BREW) && (product->miscs.at(i).use_use == MISC_USES_SPARGE)) ||
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
276 ((product->inventory_reduced <= PROD_STAGE_PRIMARY) && (product->miscs.at(i).use_use == MISC_USES_PRIMARY)) ||
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
277 ((product->inventory_reduced <= PROD_STAGE_TERTIARY) && (product->miscs.at(i).use_use == MISC_USES_SECONDARY)) ||
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
278 ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->miscs.at(i).use_use == MISC_USES_BOTTLING))) &&
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
279 (product->miscs.at(i).inventory < product->miscs.at(i).amount)) {
194
ea8cce5e7eb9 Added calcMiscs(). In miscs check supplies. Update inventory check when setting a new brewing salt. Use enum constants to make code more readable.
Michiel Broek <mbroek@mbse.eu>
parents: 190
diff changeset
280 product->miscs_ok = false;
ea8cce5e7eb9 Added calcMiscs(). In miscs check supplies. Update inventory check when setting a new brewing salt. Use enum constants to make code more readable.
Michiel Broek <mbroek@mbse.eu>
parents: 190
diff changeset
281 }
ea8cce5e7eb9 Added calcMiscs(). In miscs check supplies. Update inventory check when setting a new brewing salt. Use enum constants to make code more readable.
Michiel Broek <mbroek@mbse.eu>
parents: 190
diff changeset
282 }
ea8cce5e7eb9 Added calcMiscs(). In miscs check supplies. Update inventory check when setting a new brewing salt. Use enum constants to make code more readable.
Michiel Broek <mbroek@mbse.eu>
parents: 190
diff changeset
283 }
ea8cce5e7eb9 Added calcMiscs(). In miscs check supplies. Update inventory check when setting a new brewing salt. Use enum constants to make code more readable.
Michiel Broek <mbroek@mbse.eu>
parents: 190
diff changeset
284
ea8cce5e7eb9 Added calcMiscs(). In miscs check supplies. Update inventory check when setting a new brewing salt. Use enum constants to make code more readable.
Michiel Broek <mbroek@mbse.eu>
parents: 190
diff changeset
285
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
286 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
287 * Manipulate the memory array and update the miscs table.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
288 */
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
289 void EditProduct::brewing_salt_sub(QString salt, double val, int use)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
290 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
291 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
292
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
293 val = round(val * 100.0) / 100.0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
294 if (val == 0) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
295 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
296 * Remove this salt if it is in the table.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
297 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
298 for (int i = 0; i < product->miscs.size(); i++) {
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
299 if (salt.contains(product->miscs.at(i).name) && product->miscs.at(i).use_use == use) {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
300 qDebug() << " brewing_salt_sub delete" << salt << use;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
301 product->miscs.removeAt(i);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
302 refreshMiscs();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
303 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
304 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
305 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
306 qDebug() << " brewing_salt_sub delete error";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
307 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
308 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
309
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
310 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
311 * First see if this salt is in the table.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
312 * If it is, update the amount.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
313 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
314 for (int i = 0; i < product->miscs.size(); i++) {
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
315 if (salt.contains(product->miscs.at(i).name) && product->miscs.at(i).use_use == use) {
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
316 product->miscs[i].amount = val / 1000.0;
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
317 if (product->miscs.at(i).amount_is_weight)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
318 item = new QTableWidgetItem(QString("%1 gr").arg(val, 3, 'f', 2, '0'));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
319 else
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
320 item = new QTableWidgetItem(QString("%1 ml").arg(val, 3, 'f', 2, '0'));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
321 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
322 ui->miscsTable->setItem(i, 4, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
323 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
324 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
325 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
326
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
327 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
328 * We need a new entry. Search in the database is tricky because
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
329 * we are here with possible more names for the same salt. The
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
330 * name can be like 'Lactic Melkzuur'. So we select only the
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
331 * brewing salts and manually check their names.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
332 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
333 QSqlQuery query("SELECT * FROM inventory_miscs WHERE type = 4");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
334 while (query.next()) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
335 if (salt.contains(query.value(1).toString())) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
336 qDebug() << " found it, append";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
337 Miscs m;
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
338 m.name = query.value(1).toString();
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
339 m.amount = val / 1000.0;
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
340 m.type = query.value(2).toInt();
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
341 m.use_use = use;
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
342 m.time = query.value(4).toDouble();
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
343 m.amount_is_weight = query.value(5).toInt() ? true:false;
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
344 m.cost = query.value(10).toDouble();
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
345 m.inventory = query.value(9).toDouble();
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
346 product->miscs.append(m);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
347 refreshMiscs();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
348 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
349 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
350 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
351
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
352 qDebug() << "brewing_salt_sub, nothing done." << salt << val << use;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
353 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
354
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
355
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
356 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
357 * Edit brewing salt and recalculate.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
358 */
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
359 void EditProduct::set_brewing_salt(QString salt, double val, int use)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
360 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
361 val = round(val * 100.0) / 100.0;
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
362 qDebug() << "set_brewing_salt" << salt << val << use;
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
363 brewing_salt_sub(salt, val, use);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
364 calcWater();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
365 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
366 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
367
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
368
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
369 void EditProduct::addMiscRow_clicked()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
370 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
371 Miscs newm;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
372
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
373 for (int i = 0; i < product->miscs.size(); i++) {
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
374 if (product->miscs.at(i).amount == 0)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
375 return; // Add only one at a time.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
376 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
377
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
378 newm.name = "Select one";
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
379 newm.amount = 0;
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
380 newm.type = MISC_TYPES_SPICE;
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
381 newm.use_use = MISC_USES_STARTER;
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
382 newm.time = 0;
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
383 newm.amount_is_weight = true;
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
384 newm.cost = 0;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
385 product->miscs.append(newm);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
386 is_changed();
260
42b88d85fefc Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.
Michiel Broek <mbroek@mbse.eu>
parents: 194
diff changeset
387 refreshMiscs();
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
388 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
389
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
390
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
391 void EditProduct::deleteMiscRow_clicked()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
392 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
393 if (product->locked || product->miscs.size() < 1)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
394 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
395
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
396 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
397 int row = pb->objectName().toInt();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
398 qDebug() << "Delete misc row" << row << product->miscs.size();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
399
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
400 int rc = QMessageBox::warning(this, tr("Delete misc"), tr("Delete %1").arg(product->miscs.at(row).name),
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
401 QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
402 if (rc == QMessageBox::No)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
403 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
404
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
405 product->miscs.removeAt(row);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
406 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
407 emit refreshAll();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
408 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
409
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
410
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
411 void EditProduct::misc_amount_changed(double val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
412 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
413 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
414
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
415 qDebug() << "misc_amount_changed()" << product->miscs_row << val;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
416
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
417 product->miscs[product->miscs_row].amount = val / 1000.0;
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
418 if (product->miscs.at(product->miscs_row).amount_is_weight) {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
419 item = new QTableWidgetItem(QString("%1 gr").arg(product->miscs.at(product->miscs_row).amount * 1000.0, 3, 'f', 2, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
420 } else {
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
421 item = new QTableWidgetItem(QString("%1 ml").arg(product->miscs.at(product->miscs_row).amount * 1000.0, 3, 'f', 2, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
422 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
423 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
424 ui->miscsTable->setItem(product->miscs_row, 4, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
425
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
426 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
427 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
428
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
429
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
430 void EditProduct::misc_time_changed(int val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
431 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
432 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
433
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
434 qDebug() << "misc_time_changed()" << product->miscs_row << val;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
435
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
436 if (product->miscs.at(product->miscs_row).use_use == MISC_USES_BOIL) {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
437 product->miscs[product->miscs_row].time = val;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
438 item = new QTableWidgetItem(QString("%1 min.").arg(val, 1, 'f', 0, '0'));
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
439 } else if (product->miscs.at(product->miscs_row).use_use == MISC_USES_PRIMARY ||
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
440 product->miscs.at(product->miscs_row).use_use == MISC_USES_SECONDARY) {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
441 product->miscs[product->miscs_row].time = val * 1440;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
442 item = new QTableWidgetItem(QString("%1 days.").arg(val, 1, 'f', 0, '0'));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
443 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
444 item = new QTableWidgetItem(QString(""));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
445 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
446 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
447 ui->miscsTable->setItem(product->miscs_row, 3, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
448
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
449 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
450 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
451
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
452
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
453 void EditProduct::misc_select_changed(int val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
454 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
455 QSqlQuery query;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
456 bool instock = minstockEdit->isChecked();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
457 QString w;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
458 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
459
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
460 if (val < 1)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
461 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
462
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
463 qDebug() << "misc_select_changed()" << product->miscs_row << val << instock;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
464
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
465 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
466 * Search the misc ingredient pointed by the index and instock flag.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
467 */
194
ea8cce5e7eb9 Added calcMiscs(). In miscs check supplies. Update inventory check when setting a new brewing salt. Use enum constants to make code more readable.
Michiel Broek <mbroek@mbse.eu>
parents: 190
diff changeset
468 QString sql = "SELECT name,type,use_use,time,amount_is_weight,cost,inventory FROM inventory_miscs WHERE ";
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
469 if (instock)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
470 sql.append("inventory > 0 AND ");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
471 sql.append("type != 4 ORDER BY name");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
472 qDebug() << sql;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
473 query.prepare(sql);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
474 query.exec();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
475 query.first();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
476 for (int i = 0; i < (val - 1); i++) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
477 query.next();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
478 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
479 qDebug() << "found" << query.value(0).toString();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
480
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
481 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
482 * Replace the misc record contents
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
483 */
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
484 product->miscs[product->miscs_row].name = query.value(0).toString();
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
485 product->miscs[product->miscs_row].type = query.value(1).toInt();
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
486 product->miscs[product->miscs_row].use_use = query.value(2).toInt();
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
487 product->miscs[product->miscs_row].time = query.value(3).toDouble();
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
488 product->miscs[product->miscs_row].amount_is_weight = query.value(4).toInt() ? true:false;
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
489 product->miscs[product->miscs_row].cost = query.value(5).toDouble();
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
490 product->miscs[product->miscs_row].inventory = query.value(6).toDouble();
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
491
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
492 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
493 * Update the visible fields
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
494 */
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
495 mnameEdit->setText(product->miscs.at(product->miscs_row).name);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
496 ui->miscsTable->setItem(product->miscs_row, 0, new QTableWidgetItem(product->miscs.at(product->miscs_row).name));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
497
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
498 item = new QTableWidgetItem(QCoreApplication::translate("MiscType", g_misc_types[product->miscs.at(product->miscs_row).type]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
499 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
500 ui->miscsTable->setItem(product->miscs_row, 1, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
501
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
502 item = new QTableWidgetItem(QCoreApplication::translate("MiscUse", g_misc_uses[product->miscs.at(product->miscs_row).use_use]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
503 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
504 ui->miscsTable->setItem(product->miscs_row, 2, item);
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
505 useatEdit->setCurrentIndex(product->miscs.at(product->miscs_row).use_use);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
506
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
507 if (product->miscs.at(product->miscs_row).use_use == 3 || product->miscs.at(product->miscs_row).use_use == 4) { // Fermentation stages
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
508 mtimeEdit->setValue(product->miscs.at(product->miscs_row).time / 1440);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
509 mtimeEdit->setReadOnly(false);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
510 mtimeLabel->setText(tr("Time in days:"));
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
511 item = new QTableWidgetItem(QString("%1 days.").arg(product->miscs.at(product->miscs_row).time / 1440, 1, 'f', 0, '0'));
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
512 } else if (product->miscs.at(product->miscs_row).use_use == 2) { // Boil
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
513 mtimeEdit->setValue(product->miscs.at(product->miscs_row).time);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
514 mtimeEdit->setReadOnly(false);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
515 mtimeLabel->setText(tr("Time in minutes:"));
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
516 item = new QTableWidgetItem(QString("%1 min.").arg(product->miscs.at(product->miscs_row).time, 1, 'f', 0, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
517 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
518 mtimeEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
519 mtimeLabel->setText("");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
520 item = new QTableWidgetItem(QString(""));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
521 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
522 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
523 ui->miscsTable->setItem(product->miscs_row, 3, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
524
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
525 if (product->miscs.at(product->miscs_row).amount_is_weight) {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
526 mamountLabel->setText(tr("Amount in gr:"));
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
527 item = new QTableWidgetItem(QString("%1 gr").arg(product->miscs.at(product->miscs_row).amount * 1000.0, 3, 'f', 2, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
528 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
529 mamountLabel->setText(tr("Amount in ml:"));
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
530 item = new QTableWidgetItem(QString("%1 ml").arg(product->miscs.at(product->miscs_row).amount * 1000.0, 3, 'f', 2, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
531 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
532 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
533 ui->miscsTable->setItem(product->miscs_row, 4, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
534
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
535 if (product->miscs.at(product->miscs_row).amount_is_weight)
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
536 item = new QTableWidgetItem(QString("%1 gr").arg(product->miscs.at(product->miscs_row).inventory * 1000.0, 3, 'f', 2, '0'));
194
ea8cce5e7eb9 Added calcMiscs(). In miscs check supplies. Update inventory check when setting a new brewing salt. Use enum constants to make code more readable.
Michiel Broek <mbroek@mbse.eu>
parents: 190
diff changeset
537 else
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
538 item = new QTableWidgetItem(QString("%1 ml").arg(product->miscs.at(product->miscs_row).inventory * 1000.0, 3, 'f', 2, '0'));
194
ea8cce5e7eb9 Added calcMiscs(). In miscs check supplies. Update inventory check when setting a new brewing salt. Use enum constants to make code more readable.
Michiel Broek <mbroek@mbse.eu>
parents: 190
diff changeset
539 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
540 if (product->miscs.at(product->miscs_row).inventory < product->miscs.at(product->miscs_row).amount)
194
ea8cce5e7eb9 Added calcMiscs(). In miscs check supplies. Update inventory check when setting a new brewing salt. Use enum constants to make code more readable.
Michiel Broek <mbroek@mbse.eu>
parents: 190
diff changeset
541 item->setForeground(QBrush(QColor(Qt::red)));
ea8cce5e7eb9 Added calcMiscs(). In miscs check supplies. Update inventory check when setting a new brewing salt. Use enum constants to make code more readable.
Michiel Broek <mbroek@mbse.eu>
parents: 190
diff changeset
542 ui->miscsTable->setItem(product->miscs_row, 5, item);
ea8cce5e7eb9 Added calcMiscs(). In miscs check supplies. Update inventory check when setting a new brewing salt. Use enum constants to make code more readable.
Michiel Broek <mbroek@mbse.eu>
parents: 190
diff changeset
543
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
544 is_changed();
260
42b88d85fefc Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.
Michiel Broek <mbroek@mbse.eu>
parents: 194
diff changeset
545 qDebug() << "before" << product->miscs_row;
42b88d85fefc Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.
Michiel Broek <mbroek@mbse.eu>
parents: 194
diff changeset
546 refreshMiscs();
42b88d85fefc Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.
Michiel Broek <mbroek@mbse.eu>
parents: 194
diff changeset
547 /*
42b88d85fefc Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.
Michiel Broek <mbroek@mbse.eu>
parents: 194
diff changeset
548 * The order of the list is changed, lookup the item we just added.
42b88d85fefc Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.
Michiel Broek <mbroek@mbse.eu>
parents: 194
diff changeset
549 */
42b88d85fefc Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.
Michiel Broek <mbroek@mbse.eu>
parents: 194
diff changeset
550 for (int i = 0; i < product->miscs.size(); i++) {
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
551 if ((product->miscs.at(i).name == query.value(0).toString()) &&
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
552 (product->miscs.at(i).type == query.value(1).toInt()) &&
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
553 (product->miscs.at(i).use_use == query.value(2).toInt())) {
260
42b88d85fefc Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.
Michiel Broek <mbroek@mbse.eu>
parents: 194
diff changeset
554 product->miscs_row = i;
42b88d85fefc Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.
Michiel Broek <mbroek@mbse.eu>
parents: 194
diff changeset
555 break;
42b88d85fefc Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.
Michiel Broek <mbroek@mbse.eu>
parents: 194
diff changeset
556 }
42b88d85fefc Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.
Michiel Broek <mbroek@mbse.eu>
parents: 194
diff changeset
557 }
42b88d85fefc Fix default divide_size field in products. Update miscs table column 6 and 7 tooltips and display of the buttons after sort. After a new misc product is selected, update the current row index because the row may be moved. Fix some display misc values in the checklist, they were not multiplied by 1000. Fix display of some bars if the value was 24.
Michiel Broek <mbroek@mbse.eu>
parents: 194
diff changeset
558 qDebug() << "after" << product->miscs_row;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
559 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
560
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
561
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
562 void EditProduct::misc_instock_changed(bool val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
563 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
564 QSqlQuery query;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
565
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
566 qDebug() << "misc_instock_changed()" << product->miscs_row << val;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
567
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
568 this->mselectEdit->setCurrentIndex(-1);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
569 this->mselectEdit->clear();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
570 QString sql = "SELECT name,type,amount_is_weight,inventory FROM inventory_miscs WHERE ";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
571 if (val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
572 sql.append("inventory > 0 AND ");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
573 sql.append("type != 4 ORDER BY name");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
574 query.prepare(sql);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
575 query.exec();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
576 query.first();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
577 this->mselectEdit->addItem(""); // Start with empty value
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
578 for (int i = 0; i < query.size(); i++) {
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
579 this->mselectEdit->addItem(query.value(0).toString()+ " (" + QCoreApplication::translate("MiscType", g_misc_types[query.value(1).toInt()]) + ") " +
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
580 QString("%1 %2").arg(query.value(3).toDouble() * 1000.0, 3, 'f', 2, '0').arg(query.value(2).toInt()?"gr":"ml"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
581 query.next();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
582 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
583 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
584
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
585
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
586 void EditProduct::misc_useat_changed(int val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
587 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
588 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
589
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
590 qDebug() << "misc_useat_changed" << val;
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
591 product->miscs[product->miscs_row].use_use = val;
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 280
diff changeset
592 item = new QTableWidgetItem(QCoreApplication::translate("MiscUse", g_misc_uses[val]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
593 item->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
594 ui->miscsTable->setItem(product->miscs_row, 2, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
595
194
ea8cce5e7eb9 Added calcMiscs(). In miscs check supplies. Update inventory check when setting a new brewing salt. Use enum constants to make code more readable.
Michiel Broek <mbroek@mbse.eu>
parents: 190
diff changeset
596 if (val == MISC_USES_PRIMARY || val == MISC_USES_SECONDARY) {
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
597 product->miscs[product->miscs_row].time = mtimeEdit->value() * 1440;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
598 mtimeEdit->setReadOnly(false);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
599 mtimeLabel->setText(tr("Time in days:"));
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
600 item = new QTableWidgetItem(QString("%1 days.").arg(product->miscs.at(product->miscs_row).time / 1440, 1, 'f', 0, '0'));
194
ea8cce5e7eb9 Added calcMiscs(). In miscs check supplies. Update inventory check when setting a new brewing salt. Use enum constants to make code more readable.
Michiel Broek <mbroek@mbse.eu>
parents: 190
diff changeset
601 } else if (val == MISC_USES_BOIL) {
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
602 product->miscs[product->miscs_row].time = mtimeEdit->value();
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
603 mtimeEdit->setReadOnly(false);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
604 mtimeLabel->setText(tr("Time in minutes:"));
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
605 item = new QTableWidgetItem(QString("%1 min.").arg(product->miscs.at(product->miscs_row).time, 1, 'f', 0, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
606 } else {
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
607 product->miscs[product->miscs_row].time = 0;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
608 mtimeEdit->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
609 mtimeEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
610 mtimeLabel->setText("");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
611 item = new QTableWidgetItem(QString(""));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
612 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
613 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
614 ui->miscsTable->setItem(product->miscs_row, 3, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
615
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
616 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
617 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
618
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
619
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
620 void EditProduct::editMiscRow_clicked()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
621 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
622 QSqlQuery query;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
623
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
624 if (product->locked)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
625 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
626
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
627 QPushButton *pb = qobject_cast<QPushButton *>(QObject::sender());
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
628 product->miscs_row = pb->objectName().toInt();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
629 qDebug() << "Edit misc row" << product->miscs_row;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
630 Miscs backup = product->miscs.at(product->miscs_row);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
631
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
632 QDialog* dialog = new QDialog(this);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
633 dialog->resize(738, 230);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
634 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
635 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
636 buttonBox->setGeometry(QRect(30, 180, 671, 32));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
637 buttonBox->setLayoutDirection(Qt::LeftToRight);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
638 buttonBox->setOrientation(Qt::Horizontal);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
639 buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
640 buttonBox->setCenterButtons(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
641
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
642 QLabel *nameLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
643 nameLabel->setObjectName(QString::fromUtf8("nameLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
644 nameLabel->setText(tr("Current ingredient:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
645 nameLabel->setGeometry(QRect(10, 10, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
646 nameLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
647
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
648 mamountLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
649 mamountLabel->setObjectName(QString::fromUtf8("mamountLabel"));
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
650 if (product->miscs.at(product->miscs_row).amount_is_weight)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
651 mamountLabel->setText(tr("Amount in gr:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
652 else
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
653 mamountLabel->setText(tr("Amount in ml:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
654 mamountLabel->setGeometry(QRect(10, 70, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
655 mamountLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
656
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
657 mtimeLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
658 mtimeLabel->setObjectName(QString::fromUtf8("mtimeLabel"));
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
659 if (product->miscs.at(product->miscs_row).use_use == MISC_USES_PRIMARY || product->miscs.at(product->miscs_row).use_use == MISC_USES_SECONDARY)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
660 mtimeLabel->setText(tr("Time in days:"));
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
661 else if (product->miscs.at(product->miscs_row).use_use == MISC_USES_BOIL)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
662 mtimeLabel->setText(tr("Time in minutes:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
663 else
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
664 mtimeLabel->setText("");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
665 mtimeLabel->setGeometry(QRect(10, 100, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
666 mtimeLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
667
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
668 QLabel *selectLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
669 selectLabel->setObjectName(QString::fromUtf8("selectLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
670 selectLabel->setText(tr("Select ingredient:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
671 selectLabel->setGeometry(QRect(10, 40, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
672 selectLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
673 QLabel *instockLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
674 instockLabel->setObjectName(QString::fromUtf8("instockLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
675 instockLabel->setText(tr("In stock:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
676 instockLabel->setGeometry(QRect(525, 40, 121, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
677 instockLabel->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
678
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
679 mselectEdit = new QComboBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
680 mselectEdit->setObjectName(QString::fromUtf8("selectEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
681 mselectEdit->setGeometry(QRect(160, 40, 371, 23));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
682
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
683 mnameEdit = new QLineEdit(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
684 mnameEdit->setObjectName(QString::fromUtf8("mnameEdit"));
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
685 mnameEdit->setText(product->miscs.at(product->miscs_row).name);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
686 mnameEdit->setGeometry(QRect(160, 10, 511, 23));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
687 mnameEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
688
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
689 mamountEdit = new QDoubleSpinBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
690 mamountEdit->setObjectName(QString::fromUtf8("mamountEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
691 mamountEdit->setGeometry(QRect(160, 70, 121, 24));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
692 mamountEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
693 mamountEdit->setAccelerated(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
694 mamountEdit->setDecimals(2);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
695 mamountEdit->setMaximum(1000000.0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
696 mamountEdit->setSingleStep(0.1);
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
697 mamountEdit->setValue(product->miscs.at(product->miscs_row).amount * 1000.0);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
698
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
699 mtimeEdit = new QSpinBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
700 mtimeEdit->setObjectName(QString::fromUtf8("mtimeEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
701 mtimeEdit->setGeometry(QRect(160, 100, 121, 24));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
702 mtimeEdit->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
703 mtimeEdit->setAccelerated(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
704 mtimeEdit->setMaximum(10000.0);
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
705 if (product->miscs.at(product->miscs_row).use_use == MISC_USES_PRIMARY || product->miscs.at(product->miscs_row).use_use == MISC_USES_SECONDARY) {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
706 mtimeEdit->setValue(product->miscs.at(product->miscs_row).time / 1440);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
707 mtimeEdit->setReadOnly(false);
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
708 } else if (product->miscs.at(product->miscs_row).use_use == MISC_USES_BOIL) {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
709 mtimeEdit->setValue(product->miscs.at(product->miscs_row).time);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
710 mtimeEdit->setReadOnly(false);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
711 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
712 mtimeEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
713 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
714
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
715 useatEdit = new QComboBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
716 useatEdit->setObjectName(QString::fromUtf8("useatEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
717 useatEdit->setGeometry(QRect(160, 130, 161, 23));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
718 useatEdit->addItem(tr("Starter"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
719 useatEdit->addItem(tr("Mash"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
720 useatEdit->addItem(tr("Boil"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
721 useatEdit->addItem(tr("Primary"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
722 useatEdit->addItem(tr("Secondary"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
723 useatEdit->addItem(tr("Bottling"));
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
724 useatEdit->addItem(tr("Sparge"));
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
725 useatEdit->setCurrentIndex(product->miscs.at(product->miscs_row).use_use);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
726
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
727 minstockEdit = new QCheckBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
728 minstockEdit->setObjectName(QString::fromUtf8("minstockEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
729 minstockEdit->setGeometry(QRect(655, 40, 85, 21));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
730 minstockEdit->setChecked(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
731
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
732 misc_instock_changed(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
733
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
734 connect(mselectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::misc_select_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
735 connect(mamountEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::misc_amount_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
736 connect(mtimeEdit, QOverload<int>::of(&QSpinBox::valueChanged), this, &EditProduct::misc_time_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
737 connect(useatEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::misc_useat_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
738 connect(minstockEdit, &QCheckBox::stateChanged, this, &EditProduct::misc_instock_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
739 connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
740 connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
741
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
742 dialog->setModal(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
743 dialog->exec();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
744 if (dialog->result() == QDialog::Rejected) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
745 qDebug() << "reject and rollback";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
746 product->miscs[product->miscs_row] = backup;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
747 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
748 /* Clear time if misc is not used for boil or fermentation. */
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
749 if (! (product->miscs.at(product->miscs_row).use_use == MISC_USES_BOIL ||
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
750 product->miscs.at(product->miscs_row).use_use == MISC_USES_PRIMARY ||
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
751 product->miscs.at(product->miscs_row).use_use == MISC_USES_SECONDARY)) {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
752 if (product->miscs.at(product->miscs_row).time) {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
753 product->miscs[product->miscs_row].time = 0;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
754 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
755 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
756 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
757 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
758
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
759 disconnect(mselectEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
760 disconnect(mamountEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
761 disconnect(mtimeEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
762 disconnect(useatEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
763 disconnect(minstockEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
764 disconnect(buttonBox, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
765
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
766 emit refreshAll();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
767 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
768
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
769
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
770 void EditProduct::adjustMiscs(double factor)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
771 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
772 double amount;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
773
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
774 if (product->miscs.size() == 0)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
775 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
776
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
777 const QSignalBlocker blocker1(ui->bs_cacl2Edit);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
778 const QSignalBlocker blocker2(ui->bs_caso4Edit);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
779 const QSignalBlocker blocker3(ui->bs_mgso4Edit);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
780 const QSignalBlocker blocker4(ui->bs_naclEdit);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
781 const QSignalBlocker blocker5(ui->bs_mgcl2Edit);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
782 const QSignalBlocker blocker6(ui->bs_nahco3Edit);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
783 const QSignalBlocker blocker7(ui->bs_caco3Edit);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
784 const QSignalBlocker blocker9(ui->mw_acidvolEdit);
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
785 const QSignalBlocker blocker10(ui->ss_cacl2Edit);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
786 const QSignalBlocker blocker11(ui->ss_caso4Edit);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
787 const QSignalBlocker blocker12(ui->ss_mgso4Edit);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
788 const QSignalBlocker blocker13(ui->ss_naclEdit);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
789 const QSignalBlocker blocker14(ui->ss_mgcl2Edit);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
790
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
791 for (int i = 0; i < product->miscs.size(); i++) {
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
792 amount = product->miscs.at(i).amount * factor;
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
793 product->miscs[i].amount = amount;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
794
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
795 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
796 * Update the water agents.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
797 */
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
798 if (product->miscs.at(i).type == MISC_TYPES_WATER_AGENT && product->miscs.at(i).use_use == MISC_USES_MASH) {
280
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
799 if (product->miscs.at(i).name == "CaCl2") {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
800 ui->bs_cacl2Edit->setValue(product->miscs.at(i).amount * 1000.0);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
801 } else if (product->miscs.at(i).name == "CaSO4") {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
802 ui->bs_caso4Edit->setValue(product->miscs.at(i).amount * 1000.0);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
803 } else if (product->miscs.at(i).name == "MgSO4") {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
804 ui->bs_mgso4Edit->setValue(product->miscs.at(i).amount * 1000.0);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
805 } else if (product->miscs.at(i).name == "NaCl") {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
806 ui->bs_naclEdit->setValue(product->miscs.at(i).amount * 1000.0);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
807 } else if (product->miscs.at(i).name == "MgCl2") {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
808 ui->bs_mgcl2Edit->setValue(product->miscs.at(i).amount * 1000.0);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
809 } else if (product->miscs.at(i).name == "NaHCO3") {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
810 ui->bs_nahco3Edit->setValue(product->miscs.at(i).amount * 1000.0);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
811 } else if (product->miscs.at(i).name == "CaCO3") {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
812 ui->bs_caco3Edit->setValue(product->miscs.at(i).amount * 1000.0);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
813 } else if (product->miscs.at(i).name == "Melkzuur" || product->miscs.at(i).name == "Lactic") {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
814 ui->mw_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
815 } else if (product->miscs.at(i).name == "Zoutzuur" || product->miscs.at(i).name == "Hydrochloric") {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
816 ui->mw_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
817 } else if (product->miscs.at(i).name == "Fosforzuur" || product->miscs.at(i).name == "Phosphoric") {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
818 ui->mw_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0);
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
819 } else if (product->miscs.at(i).name == "Zwavelzuur" || product->miscs.at(i).name == "Sulfuric") {
efc213beb605 Member names of miscs normalized. This was a leftover from porting from php code.
Michiel Broek <mbroek@mbse.eu>
parents: 260
diff changeset
820 ui->mw_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
821 }
359
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
822 } else if (product->miscs.at(i).type == MISC_TYPES_WATER_AGENT && product->miscs.at(i).use_use == MISC_USES_SPARGE) {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
823 if (product->miscs.at(i).name == "CaCl2") {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
824 ui->ss_cacl2Edit->setValue(product->miscs.at(i).amount * 1000.0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
825 } else if (product->miscs.at(i).name == "CaSO4") {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
826 ui->ss_caso4Edit->setValue(product->miscs.at(i).amount * 1000.0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
827 } else if (product->miscs.at(i).name == "MgSO4") {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
828 ui->ss_mgso4Edit->setValue(product->miscs.at(i).amount * 1000.0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
829 } else if (product->miscs.at(i).name == "NaCl") {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
830 ui->ss_naclEdit->setValue(product->miscs.at(i).amount * 1000.0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
831 } else if (product->miscs.at(i).name == "MgCl2") {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
832 ui->ss_mgcl2Edit->setValue(product->miscs.at(i).amount * 1000.0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
833 } else if (product->miscs.at(i).name == "Melkzuur" || product->miscs.at(i).name == "Lactic") {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
834 ui->sp_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
835 } else if (product->miscs.at(i).name == "Zoutzuur" || product->miscs.at(i).name == "Hydrochloric") {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
836 ui->sp_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
837 } else if (product->miscs.at(i).name == "Fosforzuur" || product->miscs.at(i).name == "Phosphoric") {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
838 ui->sp_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
839 } else if (product->miscs.at(i).name == "Zwavelzuur" || product->miscs.at(i).name == "Sulfuric") {
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
840 ui->sp_acidvolEdit->setValue(product->miscs.at(i).amount * 1000.0);
dfbb012c631c Redesign of the water tabs in product and recipe editors. Prepare for sparge water salt additions. Acid additions are now automatic or manual for mash and sparge. Fixed error in acid calculation strength. Fixed phophoric SG value.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
841 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
842 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
843 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
844 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
845
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
846

mercurial