src/EditProductTab3.cpp

Wed, 17 Aug 2022 15:23:17 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Wed, 17 Aug 2022 15:23:17 +0200
changeset 396
c9a1d85c1487
parent 390
2a69be28a925
child 397
877420a13815
permissions
-rw-r--r--

Show final OG and FG if they are valid on the first tab.

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 3, fermentables
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
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 bool EditProduct::ferment_sort_test(const Fermentables &D1, const Fermentables &D2)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
24 if (D1.added > D2.added)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 return false;
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
26 if (D1.added < D2.added)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 return true;
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
28 return (D1.amount >= D2.amount) && (D1.color < D2.color);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 void EditProduct::to100Fermentables(int row)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
34 if (product->fermentables.at(row).adjust_to_total_100) {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
35 QWidget *pWidget = new QWidget();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
36 QLabel *label = new QLabel;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
37 label->setPixmap(QPixmap(":icons/silk/tick.png"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
38 QHBoxLayout *pLayout = new QHBoxLayout(pWidget);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
39 pLayout->addWidget(label);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
40 pLayout->setAlignment(Qt::AlignCenter);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 pLayout->setContentsMargins(0, 0, 0, 0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 pWidget->setLayout(pLayout);
177
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
43 ui->fermentablesTable->setCellWidget(row, 10, pWidget);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 } else {
177
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
45 ui->fermentablesTable->removeCellWidget(row, 10);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
47 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
48
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49
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
50 bool EditProduct::block_fermentable(int stage, int added)
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
51 {
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
52 if (stage > PROD_STAGE_PACKAGE)
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
53 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
54 if (stage > PROD_STAGE_TERTIARY && added < FERMENTABLE_ADDED_BOTTLE)
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
55 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
56 if (stage > PROD_STAGE_PRIMARY && added < FERMENTABLE_ADDED_LAGERING)
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
57 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
58 if (stage > PROD_STAGE_BREW && added < FERMENTABLE_ADDED_FERMENTATION)
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
59 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
60 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
61 }
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
62
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
63
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 void EditProduct::refreshFermentables()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 QString w;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 QWidget* pWidget;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 QHBoxLayout* pLayout;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 qDebug() << "refreshFermentables" << product->fermentables.size();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 std::sort(product->fermentables.begin(), product->fermentables.end(), ferment_sort_test);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 const QStringList labels({tr("Supplier"), tr("Fermentable"), tr("EBC"), tr("Type"), tr("Graintype"), tr("When"), tr("Yield"),
177
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
75 tr("Amount"), tr("Stock"), tr("Procent"), tr("100%"), tr("Delete"), tr("Edit") });
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
76 ui->fermentablesTable->setColumnCount(13);
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
77 ui->fermentablesTable->setColumnWidth(0, 130); /* Supplier */
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
78 ui->fermentablesTable->setColumnWidth(1, 210); /* Fermentable */
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
79 ui->fermentablesTable->setColumnWidth(2, 45); /* Color */
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 ui->fermentablesTable->setColumnWidth(3, 75); /* Type */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 ui->fermentablesTable->setColumnWidth(4, 75); /* Graintype */
177
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
82 ui->fermentablesTable->setColumnWidth(5, 77); /* Added */
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
83 ui->fermentablesTable->setColumnWidth(6, 55); /* Yield */
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
84 ui->fermentablesTable->setColumnWidth(7, 80); /* Amount */
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
85 ui->fermentablesTable->setColumnWidth(8, 80); /* Stock */
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
86 ui->fermentablesTable->setColumnWidth(9, 55); /* Procent */
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
87 ui->fermentablesTable->setColumnWidth(10, 50); /* 100% */
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
88 ui->fermentablesTable->setColumnWidth(11, 80); /* Delete */
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
89 ui->fermentablesTable->setColumnWidth(12, 80); /* Edit */
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 ui->fermentablesTable->setHorizontalHeaderLabels(labels);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 ui->fermentablesTable->verticalHeader()->hide();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 ui->fermentablesTable->setRowCount(product->fermentables.size());
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 for (int i = 0; i < product->fermentables.size(); i++) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
96 ui->fermentablesTable->setItem(i, 0, new QTableWidgetItem(product->fermentables.at(i).supplier));
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
97 ui->fermentablesTable->setItem(i, 1, new QTableWidgetItem(product->fermentables.at(i).name));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
99 w = QString("%1").arg(product->fermentables.at(i).color, 1, 'f', 0, '0');
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 item = new QTableWidgetItem(w);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101 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
102 ui->fermentablesTable->setItem(i, 2, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 284
diff changeset
104 item = new QTableWidgetItem(QCoreApplication::translate("FermentableType", g_fermentable_types[product->fermentables.at(i).type]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 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
106 ui->fermentablesTable->setItem(i, 3, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 284
diff changeset
108 item = new QTableWidgetItem(QCoreApplication::translate("FermentableGraintype", g_fermentable_graintypes[product->fermentables.at(i).graintype]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 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
110 ui->fermentablesTable->setItem(i, 4, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
111
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 284
diff changeset
112 item = new QTableWidgetItem(QCoreApplication::translate("FermentableAdded", g_fermentable_added[product->fermentables.at(i).added]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 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
114 ui->fermentablesTable->setItem(i, 5, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
116 item = new QTableWidgetItem(QString("%1%").arg(product->fermentables.at(i).yield, 2, 'f', 1, '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->fermentablesTable->setItem(i, 6, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
120 item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables.at(i).amount, 4, 'f', 3, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 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
122 ui->fermentablesTable->setItem(i, 7, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123
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
124 if (block_fermentable(product->stage, product->fermentables.at(i).added)) {
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 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
126 } 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
127 item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables.at(i).inventory, 4, 'f', 3, '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
128 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
129 if (product->fermentables.at(i).inventory < product->fermentables.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
130 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
131 }
177
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
132 ui->fermentablesTable->setItem(i, 8, item);
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
133
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
134 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) {
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
135 item = new QTableWidgetItem(QString("%1%").arg(product->fermentables.at(i).percentage, 2, 'f', 1, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
136 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
137 item = new QTableWidgetItem(QString("")); // Blank for bottling and kegging.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
138 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
139 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
177
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
140 ui->fermentablesTable->setItem(i, 9, item);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
141
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
142 to100Fermentables(i);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
143
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
144 /* Add the Delete and Edit row buttons if allowed. */
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
145 if (product->fermentables.at(i).added >= FERMENTABLE_ADDED_BOTTLE) {
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
146 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
147 item->setToolTip(tr("Edit this from the package tab"));
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->fermentablesTable->setItem(i, 11, 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
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("Edit this from the package tab"));
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->fermentablesTable->setItem(i, 12, 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 } else if (block_fermentable(product->stage, product->fermentables.at(i).added)) {
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("Fermentable 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->fermentablesTable->setItem(i, 11, 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
156 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
157 item->setToolTip(tr("Fermentable 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
158 ui->fermentablesTable->setItem(i, 12, 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
159 } else {
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: 187
diff changeset
160 pWidget = new QWidget();
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: 187
diff changeset
161 QPushButton* btn_dele = new QPushButton();
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: 187
diff changeset
162 btn_dele->setObjectName(QString("%1").arg(i)); /* Send row with the button */
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: 187
diff changeset
163 btn_dele->setText(tr("Delete"));
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: 187
diff changeset
164 connect(btn_dele, SIGNAL(clicked()), this, SLOT(deleteFermentRow_clicked()));
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: 187
diff changeset
165 pLayout = new QHBoxLayout(pWidget);
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: 187
diff changeset
166 pLayout->addWidget(btn_dele);
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: 187
diff changeset
167 pLayout->setContentsMargins(5, 0, 5, 0);
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: 187
diff changeset
168 pWidget->setLayout(pLayout);
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: 187
diff changeset
169 ui->fermentablesTable->setCellWidget(i, 11, pWidget);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
170
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: 187
diff changeset
171 pWidget = new QWidget();
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: 187
diff changeset
172 QPushButton* btn_edit = new QPushButton();
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: 187
diff changeset
173 btn_edit->setObjectName(QString("%1").arg(i)); /* Send row with the button */
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: 187
diff changeset
174 btn_edit->setText(tr("Edit"));
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: 187
diff changeset
175 connect(btn_edit, SIGNAL(clicked()), this, SLOT(editFermentRow_clicked()));
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: 187
diff changeset
176 pLayout = new QHBoxLayout(pWidget);
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: 187
diff changeset
177 pLayout->addWidget(btn_edit);
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: 187
diff changeset
178 pLayout->setContentsMargins(5, 0, 5, 0);
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: 187
diff changeset
179 pWidget->setLayout(pLayout);
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: 187
diff changeset
180 ui->fermentablesTable->setCellWidget(i, 12, pWidget);
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: 187
diff changeset
181 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
182 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
183 }
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 void EditProduct::calcFermentables()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
187 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
188 int i;
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: 187
diff changeset
189 double psugar = 0, pcara = 0, d, s = 0, x, cw, color;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
190 double vol = 0; // Volume sugars after boil
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
191 double addedS = 0; // Added sugars after boil
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
192 double addedmass = 0; // Added mass after boil
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
193 double mvol = 0; // Mash volume
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
194 double lintner = 0; // Total product lintner
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
195 double sugarsf = 0; // fermentable sugars mash + boil
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
196 double sugarsm = 0; // fermentable sugars in mash
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
197 double sugardensity = 1.611; // kg/l in solution
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
198 double mashtime = 0; // Total mash time
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
199 double mashtemp = 0; // Average mash temperature
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
200 double mashinfuse = 0; // Mash infuse amount
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
201 double colort = 0; // Colors srm * vol totals
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
202 double colorh = 0; // Colors ebc * vol * kt
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
203 double colorn = 0; // Colors ebc * pt * pct
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: 187
diff changeset
204 double bv = 0.925; // Beer loss efficiency
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: 187
diff changeset
205 double sr = 0.95; // Mash and sparge efficiency
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
206
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
207 qDebug() << "calcFermentables()";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
208
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
209 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
210 * Get average mashtemp and mashtime from the Mash schedule.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
211 * It is possible that the schedule is not (yet) present.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
212 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
213 if (product->mashs.size() > 0) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
214 for (i = 0; i < product->mashs.size(); i++) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
215 if (product->mashs.at(i).step_type == 0) // Infusion
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
216 mashinfuse += product->mashs.at(i).step_infuse_amount;
390
2a69be28a925 Fixed calculation of estimated fg.
Michiel Broek <mbroek@mbse.eu>
parents: 369
diff changeset
217 if (product->mashs.at(i).step_temp <= 75 && product->mashs.at(i).step_temp >= 60) { // Ignore mashout and low temperatures.
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: 187
diff changeset
218 double timem = product->mashs.at(i).step_time;
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: 187
diff changeset
219 if (i > 0)
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: 187
diff changeset
220 timem += product->mashs.at(i).ramp_time;
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: 187
diff changeset
221 mashtime += timem;
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: 187
diff changeset
222 mashtemp += timem * product->mashs.at(i).step_temp;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
223 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
224 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
225 mashtemp = mashtemp / mashtime;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
226 mvol = mashinfuse;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
227 qDebug() << " mash time" << mashtime << "temp" << mashtemp << "infuse" << mashinfuse;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
228 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
229 qDebug() << " no mash schedule";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
230 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
231
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
232 const QSignalBlocker blocker1(ui->est_ogEdit);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
233 const QSignalBlocker blocker2(ui->est_og2Edit);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
234
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
235 if (product->fermentables.size() < 1) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
236 qDebug() << " no fermentables, return.";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
237 product->est_og = 0.980;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
238 ui->est_ogEdit->setValue(0.980);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
239 ui->est_og2Edit->setValue(0.980);
181
14a1f7bca79b Added missing est_og3 database field load and save. Added all extra fields in update and insert product. Renamed est_og3Edit on tab 3 to est_og4Edit because est_og3Edit is reserved for the brewday tab.
Michiel Broek <mbroek@mbse.eu>
parents: 177
diff changeset
240 ui->est_og4Edit->setValue(0.980);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
241 ui->est_ogShow->setValue(0.980);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
242 product->est_color = 0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
243 ui->est_colorEdit->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
244 ui->est_colorEdit->setStyleSheet(Utils::ebc_to_style(0));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
245 ui->est_color2Edit->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
246 ui->est_color2Edit->setStyleSheet(Utils::ebc_to_style(0));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
247 ui->est_colorShow->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
248 ui->perc_mashShow->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
249 ui->perc_sugarsShow->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
250 ui->perc_caraShow->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
251 ui->lintnerShow->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
252 product->est_fg = 0.980;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
253 ui->est_fgEdit->setValue(0.980);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
254 ui->est_fg3Edit->setValue(0.980);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
255 ui->est_fgShow->setValue(0.980);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
256 ui->est_abvEdit->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
257 ui->est_abv2Edit->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
258 ui->est_abvShow->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
259 product->est_abv = 0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
260 ui->calEdit->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
261 product->mashs_kg = 0;
177
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
262 ui->mash_kgEdit->setValue(0);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
263 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
264 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
265 qDebug() << " adjust to 100" << product->fermentables_use100;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
266
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: 187
diff changeset
267 product->fermentables_ok = true;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
268 product->mashs_kg = 0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
269 for (i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
270 if (product->fermentables.at(i).type == FERMENTABLE_TYPE_SUGAR && product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE)
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
271 psugar += product->fermentables.at(i).percentage;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
272 if (product->fermentables.at(i).graintype == FERMENTABLE_GRAINTYPE_CRYSTAL && product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE)
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
273 pcara += product->fermentables.at(i).percentage;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
274 d = product->fermentables.at(i).amount * (product->fermentables.at(i).yield / 100) * (1 - product->fermentables.at(i).moisture / 100);
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
275 if (product->fermentables.at(i).added == FERMENTABLE_ADDED_MASH) {
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: 187
diff changeset
276 if (mvol > 0) { // If mash volume is known
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
277 mvol += product->fermentables.at(i).amount * product->fermentables.at(i).moisture / 100;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
278 s += d;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
279 }
184
da148d6b4c95 Added brewday boil box. The setLocked function changed into setStage. Fixed bug that resetted the efficiency to the equipment default.
Michiel Broek <mbroek@mbse.eu>
parents: 182
diff changeset
280 d = product->efficiency / 100 * d;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
281 sugarsm += d;
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
282 product->mashs_kg += product->fermentables.at(i).amount;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
283 }
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
284 if (product->fermentables.at(i).added == FERMENTABLE_ADDED_MASH || product->fermentables.at(i).added == FERMENTABLE_ADDED_BOIL)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
285 sugarsf += d;
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
286 if (product->fermentables.at(i).added == FERMENTABLE_ADDED_FERMENTATION || product->fermentables.at(i).added == FERMENTABLE_ADDED_LAGERING) {
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
287 x = (product->fermentables.at(i).yield / 100) * (1 - product->fermentables.at(i).moisture / 100);
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
288 addedS += product->fermentables.at(i).amount * x;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
289 addedmass += product->fermentables.at(i).amount;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
290 vol += (x * sugardensity + (1 - x) * 1) * product->fermentables.at(i).amount;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
291 }
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
292 if (product->fermentables.at(i).added == FERMENTABLE_ADDED_MASH &&
369
09d3d8d18f97 Version 0.2.20. Calculate total linther ignore malt color because our database is correct.
Michiel Broek <mbroek@mbse.eu>
parents: 363
diff changeset
293 (product->fermentables.at(i).type == FERMENTABLE_TYPE_GRAIN || product->fermentables.at(i).type == FERMENTABLE_TYPE_ADJUCT)) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
294 lintner += product->fermentables.at(i).diastatic_power * product->fermentables.at(i).amount;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
295 }
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
296 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) {
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
297 colort += product->fermentables.at(i).amount * Utils::ebc_to_srm(product->fermentables.at(i).color);
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
298 colorh += product->fermentables.at(i).amount * product->fermentables.at(i).color * Utils::get_kt(product->fermentables.at(i).color);
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
299 colorn += (product->fermentables.at(i).percentage / 100) * product->fermentables.at(i).color; // For 8.6 Pt wort.
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
300 }
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: 187
diff changeset
301 /* Check supplies */
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
302 if ((((product->inventory_reduced <= PROD_STAGE_BREW) && (product->fermentables.at(i).added <= FERMENTABLE_ADDED_BOIL)) ||
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
303 ((product->inventory_reduced <= PROD_STAGE_PRIMARY) && (product->fermentables.at(i).added == FERMENTABLE_ADDED_FERMENTATION)) ||
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
304 ((product->inventory_reduced <= PROD_STAGE_TERTIARY) && (product->fermentables.at(i).added == FERMENTABLE_ADDED_LAGERING)) ||
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
305 ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->fermentables.at(i).added == FERMENTABLE_ADDED_BOTTLE)) ||
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
306 ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->fermentables.at(i).added == FERMENTABLE_ADDED_KEGS))) &&
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
307 product->fermentables.at(i).inventory < product->fermentables.at(i).amount) {
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: 187
diff changeset
308 product->fermentables_ok = false;
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: 187
diff changeset
309 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
310 }
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: 187
diff changeset
311 qDebug() << " supplies" << product->fermentables_ok;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
312 qDebug() << " colort" << colort << "colorh" << colorh << "colorn" << colorn;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
313 qDebug() << " psugar" << psugar << "pcara" << pcara << "mvol" << mvol;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
314 qDebug() << " sugarsf" << sugarsf << "sugarsm" << sugarsm;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
315
182
545d31130844 Added brewday mash results box.
Michiel Broek <mbroek@mbse.eu>
parents: 181
diff changeset
316 double v = s / sugardensity + mvol;
545d31130844 Added brewday mash results box.
Michiel Broek <mbroek@mbse.eu>
parents: 181
diff changeset
317 s = 1000 * s / (v * 10); //deg. Plato
545d31130844 Added brewday mash results box.
Michiel Broek <mbroek@mbse.eu>
parents: 181
diff changeset
318 product->est_mash_sg = Utils::plato_to_sg(s);
545d31130844 Added brewday mash results box.
Michiel Broek <mbroek@mbse.eu>
parents: 181
diff changeset
319 ui->brew_mashsgShow->setValue(product->est_mash_sg);
545d31130844 Added brewday mash results box.
Michiel Broek <mbroek@mbse.eu>
parents: 181
diff changeset
320
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: 187
diff changeset
321 /* Estimate total recipe OG */
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: 187
diff changeset
322 product->est_og = Utils::estimate_sg(sugarsf + addedS, product->batch_size);
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: 187
diff changeset
323 qDebug() << " OG" << ui->est_ogEdit->value() << product->est_og;
396
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
324 if (product->stage > PROD_STAGE_BREW) {
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
325 ui->est_ogLabel->setText(tr("Final OG"));
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
326 ui->est_ogEdit->setValue(product->og);
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
327 ui->est_ogShow->setValue(product->og);
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
328 } else {
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
329 ui->est_ogEdit->setValue(product->est_og);
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
330 ui->est_ogShow->setValue(product->est_og);
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
331 }
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: 187
diff changeset
332 ui->est_og2Edit->setValue(product->est_og);
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: 187
diff changeset
333 ui->est_og4Edit->setValue(product->est_og);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
334
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: 187
diff changeset
335 /* Estimate SG in kettle after boil */
184
da148d6b4c95 Added brewday boil box. The setLocked function changed into setStage. Fixed bug that resetted the efficiency to the equipment default.
Michiel Broek <mbroek@mbse.eu>
parents: 182
diff changeset
336 product->est_og3 = Utils::estimate_sg(sugarsf, product->batch_size);
da148d6b4c95 Added brewday boil box. The setLocked function changed into setStage. Fixed bug that resetted the efficiency to the equipment default.
Michiel Broek <mbroek@mbse.eu>
parents: 182
diff changeset
337 ui->brew_aboilsgShow->setValue(product->est_og3);
da148d6b4c95 Added brewday boil box. The setLocked function changed into setStage. Fixed bug that resetted the efficiency to the equipment default.
Michiel Broek <mbroek@mbse.eu>
parents: 182
diff changeset
338
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: 187
diff changeset
339 /* Estimate SG in kettle before boil */
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
340 product->preboil_sg = Utils::estimate_sg(sugarsm, product->boil_size);
184
da148d6b4c95 Added brewday boil box. The setLocked function changed into setStage. Fixed bug that resetted the efficiency to the equipment default.
Michiel Broek <mbroek@mbse.eu>
parents: 182
diff changeset
341 ui->brew_preboilsgShow->setValue(product->preboil_sg);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
342 qDebug() << " preboil SG" << product->preboil_sg;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
343
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
344 /*
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: 187
diff changeset
345 * Recalculate volumes
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: 187
diff changeset
346 */
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: 187
diff changeset
347 double aboil_volume = product->batch_size;
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: 187
diff changeset
348 if (product->brew_aboil_volume > 0)
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: 187
diff changeset
349 aboil_volume = product->brew_aboil_volume / 1.04; // Volume @ 20 degrees.
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: 187
diff changeset
350 if (product->brew_fermenter_tcloss == 0) {
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: 187
diff changeset
351 product->brew_fermenter_tcloss = product->eq_trub_chiller_loss;
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: 187
diff changeset
352 ui->brew_trublossEdit->setValue(product->brew_fermenter_tcloss);
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: 187
diff changeset
353 }
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: 187
diff changeset
354 product->brew_fermenter_volume = aboil_volume - product->brew_fermenter_tcloss + product->brew_fermenter_extrawater;
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: 187
diff changeset
355 ui->brew_tofermentEdit->setValue(product->brew_fermenter_volume);
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: 187
diff changeset
356 /* Calculate SG in fermenter */
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: 187
diff changeset
357 double ogx = product->brew_aboil_sg;
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: 187
diff changeset
358 if (ogx < 1.002)
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: 187
diff changeset
359 ogx = product->est_og3;
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: 187
diff changeset
360 double topw = product->brew_fermenter_extrawater;
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: 187
diff changeset
361
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: 187
diff changeset
362 if (product->brew_fermenter_volume > 0) {
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: 187
diff changeset
363 double sug = Utils::sg_to_plato(ogx) * product->brew_fermenter_volume * ogx / 100; //kg of sugar in
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: 187
diff changeset
364 sug += addedS; //kg
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: 187
diff changeset
365
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: 187
diff changeset
366 if ((product->brew_fermenter_volume * ogx + addedmass) > 0) {
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: 187
diff changeset
367 double pt = 100 * sug / (product->brew_fermenter_volume * ogx + addedmass + topw);
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: 187
diff changeset
368 product->og = product->brew_fermenter_sg = round(Utils::plato_to_sg(pt) * 10000) / 10000.0;
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: 187
diff changeset
369 ui->brew_fermentsgShow->setValue(product->brew_fermenter_sg);
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: 187
diff changeset
370 // color
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: 187
diff changeset
371 if (product->color_method == 4) { // Naudts
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: 187
diff changeset
372 product->brew_fermenter_color = round(((pt / 8.6) * colorn) + (product->boil_time / 60));
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: 187
diff changeset
373 } else if (product->color_method == 3) { // Hans Halberstadt
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: 187
diff changeset
374 product->brew_fermenter_color = round((4.46 * bv * sr) / (aboil_volume + topw) * colorh);
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: 187
diff changeset
375 } else {
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: 187
diff changeset
376 cw = colort / (aboil_volume + topw) * 8.34436;
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: 187
diff changeset
377 product->brew_fermenter_color = Utils::kw_to_ebc(product->color_method, cw);
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: 187
diff changeset
378 }
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: 187
diff changeset
379 ui->brew_fermentcolorShow->setValue(product->brew_fermenter_color);
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: 187
diff changeset
380 ui->brew_fermentcolorShow->setStyleSheet(Utils::ebc_to_style(product->brew_fermenter_color));
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: 187
diff changeset
381 }
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: 187
diff changeset
382 } else {
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: 187
diff changeset
383 // Negative volume
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: 187
diff changeset
384 product->brew_fermenter_sg = product->brew_fermenter_color = 0;
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: 187
diff changeset
385 ui->brew_fermentsgShow->setValue(0);
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: 187
diff changeset
386 ui->brew_fermentcolorShow->setStyleSheet(0);
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: 187
diff changeset
387 ui->brew_fermentcolorShow->setValue(0);
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: 187
diff changeset
388 }
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: 187
diff changeset
389
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: 187
diff changeset
390 /*
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
391 * Color of the wort
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->color_method == 4) { // Naudts
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: 187
diff changeset
394 color = round(((Utils::sg_to_plato(product->est_og) / 8.6) * colorn) + (product->boil_time / 60));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
395 } else if (product->color_method == 3) { // Hans Halberstadt
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
396 color = round((4.46 * bv * sr) / product->batch_size * colorh);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
397 } else {
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: 187
diff changeset
398 cw = colort / product->batch_size * 8.34436;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
399 color = Utils::kw_to_ebc(product->color_method, cw);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
400 //qDebug() << " oud EBC" << color << "new EBC" << Utils::kw_to_newebc(product->color_method, cw) << "SRM" << Utils::kw_to_srm(product->color_method, cw);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
401 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
402 qDebug() << " color" << ui->est_colorEdit->value() << color << product->est_color;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
403 product->est_color = color;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
404 ui->est_colorEdit->setValue(color);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
405 ui->est_colorEdit->setStyleSheet(Utils::ebc_to_style(color));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
406 ui->est_color2Edit->setValue(color);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
407 ui->est_color2Edit->setStyleSheet(Utils::ebc_to_style(color));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
408 ui->est_colorShow->setValue(color);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
409
363
313cdeb309d2 Fixed overloaded perc_mashShow when the value is above the maxiumum.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
410 if (round(product->mashs_kg / product->eq_mash_max * 100) > 120)
313cdeb309d2 Fixed overloaded perc_mashShow when the value is above the maxiumum.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
411 ui->perc_mashShow->setValue(120);
313cdeb309d2 Fixed overloaded perc_mashShow when the value is above the maxiumum.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
412 else
313cdeb309d2 Fixed overloaded perc_mashShow when the value is above the maxiumum.
Michiel Broek <mbroek@mbse.eu>
parents: 305
diff changeset
413 ui->perc_mashShow->setValue(round(product->mashs_kg / product->eq_mash_max * 100));
177
62b8d701cd88 Fermentables inventory is updated during initial product load. Total mash volume is calculated against the used equipment profile. Display mash weight. Mash infuse temperatures are calculated against the used equipment profile.
Michiel Broek <mbroek@mbse.eu>
parents: 175
diff changeset
414 ui->mash_kgEdit->setValue(product->mashs_kg);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
415 ui->perc_sugarsShow->setValue(round(psugar));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
416 ui->perc_caraShow->setValue(round(pcara));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
417 if (product->mashs_kg > 0) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
418 qDebug() << " lintner" << lintner << " mashkg" << product->mashs_kg << "final" << round(lintner / product->mashs_kg);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
419 ui->lintnerShow->setValue(round(lintner / product->mashs_kg));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
420 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
421 qDebug() << " lintner N/A";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
422 ui->lintnerShow->setValue(0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
423 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
424
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 * Calculate the apparant attenuation.
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 double svg = 0;
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: 187
diff changeset
429 double initcells = 0;
225
448e4187cada Implemented the tasting tab. On the generic tab, show the ingredients check or the read only prompt on the same place depending on the product stage. Fixed the yeasts ingredients in stock check. Reordered the tab order of all edit fields. It looks like this module is ready and needs testing.
Michiel Broek <mbroek@mbse.eu>
parents: 224
diff changeset
430 product->yeasts_ok = true;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
431 if (product->yeasts.size() > 0) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
432 for (i = 0; i < product->yeasts.size(); i++) {
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
433 if (product->yeasts.at(i).use == 0) { // Used in primary
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
434 if (product->yeasts.at(i).attenuation > svg)
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
435 svg = product->yeasts.at(i).attenuation; // Take the highest if multiple yeasts.
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
436 }
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
437 if (product->yeasts.at(i).form == 0)
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
438 initcells += (product->yeasts.at(i).cells / 1000000000) * product->yeasts.at(i).amount * (product->starter_viability / 100);
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: 187
diff changeset
439 else
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
440 initcells += (product->yeasts.at(i).cells / 1000000) * product->yeasts.at(i).amount * (product->starter_viability / 100);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
441 // TODO: brett or others in secondary.
284
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
442 if ((((product->inventory_reduced <= PROD_STAGE_PRIMARY) && (product->yeasts.at(i).use == 0)) || // Primary
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
443 ((product->inventory_reduced <= PROD_STAGE_SECONDARY) && (product->yeasts.at(i).use == 1)) || // Secondary
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
444 ((product->inventory_reduced <= PROD_STAGE_TERTIARY) && (product->yeasts.at(i).use == 2)) || // Tertiary
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
445 ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->yeasts.at(i).use == 3))) && // Bottle
33bb98c33e6a Member names for yeasts normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 283
diff changeset
446 (product->yeasts.at(i).inventory < product->yeasts.at(i).amount)) {
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: 187
diff changeset
447 product->yeasts_ok = false;
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: 187
diff changeset
448 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
449 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
450 qDebug() << " SVG" << svg;
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 if (svg == 0)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
453 svg = 77.0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
454 ui->est_svgEdit->setValue(svg);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
455
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
456 if (product->mashs_kg > 0 && mashinfuse > 0 && mashtime > 0 && mashtemp > 0)
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: 187
diff changeset
457 product->est_fg = Utils::estimate_fg(psugar, pcara, mashinfuse / product->mashs_kg, mashtime, mashtemp, svg, product->est_og);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
458 else
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: 187
diff changeset
459 product->est_fg = Utils::estimate_fg(psugar, pcara, 0, 0, 0, svg, product->est_og);
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: 187
diff changeset
460 qDebug() << " FG" << ui->est_fgEdit->value() << product->est_fg;
396
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
461 if (product->stage > PROD_STAGE_TERTIARY) {
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
462 ui->est_fgLabel->setText(tr("Final FG"));
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
463 ui->est_fgEdit->setValue(product->fg);
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
464 ui->est_fgShow->setValue(product->fg);
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
465 } else {
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
466 ui->est_fgEdit->setValue(product->est_fg);
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
467 ui->est_fgShow->setValue(product->est_fg);
c9a1d85c1487 Show final OG and FG if they are valid on the first tab.
Michiel Broek <mbroek@mbse.eu>
parents: 390
diff changeset
468 }
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: 187
diff changeset
469 ui->est_fg3Edit->setValue(product->est_fg);
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: 187
diff changeset
470
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: 187
diff changeset
471 product->est_abv = Utils::abvol(product->est_og, product->est_fg);
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: 187
diff changeset
472 qDebug() << " ABV" << ui->est_abvEdit->value() << product->est_abv;
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: 187
diff changeset
473 ui->est_abvEdit->setValue(product->est_abv);
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: 187
diff changeset
474 ui->est_abv2Edit->setValue(product->est_abv);
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: 187
diff changeset
475 ui->est_abvShow->setValue(product->est_abv);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
476
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
477 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
478 * Calculate kilocalories/liter. Formula from brouwhulp.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
479 * Take the alcohol and sugar parts and then combine.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
480 */
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: 187
diff changeset
481 double alc = 1881.22 * product->est_fg * (product->est_og - product->est_fg) / (1.775 - product->est_og);
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: 187
diff changeset
482 double sug = 3550 * product->est_fg * (0.1808 * product->est_og + 0.8192 * product->est_fg - 1.0004);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
483 ui->calEdit->setValue(round((alc + sug) / (12 * 0.0295735296)));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
484
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
485 // Bottle priming
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
486 double priming_total = 0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
487 for (i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
488 if (product->fermentables.at(i).added == FERMENTABLE_ADDED_BOTTLE) {
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
489 priming_total += ((product->fermentables.at(i).yield / 100) * (1 - product->fermentables.at(i).moisture / 100)) *
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
490 product->fermentables.at(i).amount;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
491 qDebug() << " priming" << product->fermentables.at(i).amount << "total" << priming_total;
175
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 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
494 double grl = priming_total * 1000.0 * (1 / product->batch_size);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
495 double volco2 = grl * 0.510;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
496 qDebug() << " priming gr/l" << grl << "volco2" << volco2;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
497
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
498 if (volco2 > 0) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
499 product->est_carb = volco2;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
500 ui->est_carbEdit->setValue(product->est_carb);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
501 ui->est_carbShow->setValue(product->est_carb);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
502 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
503 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
504
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
505
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
506 void EditProduct::calcFermentablesFromOG(double og)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
507 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
508 qDebug() << "calcFermentablesFromOG" << og;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
509
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
510 int i;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
511 double totmass = 0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
512 double tot = 0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
513 double d, amount;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
514 double efficiency = product->efficiency;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
515 double sug = Utils::sg_to_plato(og) * product->batch_size * og / 100.0; // total amount of sugars in kg.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
516
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
517 for (i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
518 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) {
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
519 d = product->fermentables.at(i).percentage / 100.0 *
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
520 (product->fermentables.at(i).yield / 100.0) *
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
521 (1 - product->fermentables.at(i).moisture / 100.0);
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
522 if (product->fermentables.at(i).added == FERMENTABLE_ADDED_MASH)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
523 d = efficiency / 100.0 * d;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
524 tot += d;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
525 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
526 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
527 if (tot)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
528 totmass = round((sug / tot) * 1000.0) / 1000.0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
529
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
530 if (totmass) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
531 for (i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
532 amount = round(product->fermentables.at(i).percentage * 10.0 * totmass) / 1000.0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
533 product->fermentables[i].amount = amount;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
534 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
535 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
536 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
537
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
538
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
539 void EditProduct::ferment_perc_mash_valueChanged(int value)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
540 {
229
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
541 if (value < 90) {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
542 ui->perc_mashShow->setStyleSheet(bar_green);
229
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
543 } else {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
544 double s1 = 90.0 / value;
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
545 if (value < 100) {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
546 ui->perc_mashShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
547 "stop: 0 green, stop: %1 green, stop: %2 orange, stop: 1 orange"
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
548 ");}").arg(s1 - 0.00001).arg(s1));
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
549 } else {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
550 double s2 = 100.0 / value;
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
551 ui->perc_mashShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
552 "stop: 0 green, stop: %1 green, stop: %2 orange, stop: %3 orange, stop: %4 red, stop: 1 red"
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
553 ");}").arg(s1 - 0.00003).arg(s1 - 0.00002).arg(s2 - 0.00001).arg(s2));
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
554 }
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
555 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
556 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
557
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
558
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
559 void EditProduct::ferment_perc_sugars_valueChanged(int value)
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 if (value < 20)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
562 ui->perc_sugarsShow->setStyleSheet(bar_green);
229
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
563 else {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
564 double s1 = 20.0 / value;
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
565 ui->perc_sugarsShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
566 "stop: 0 green, stop: %1 green, stop: %2 red, stop: 1 red);}").arg(s1 - 0.00001).arg(s1));
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
567 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
568 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
569
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
570
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
571 void EditProduct::ferment_perc_cara_valueChanged(int value)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
572 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
573 if (value < 25)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
574 ui->perc_caraShow->setStyleSheet(bar_green);
229
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
575 else {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
576 double s1 = 25.0 / value;
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
577 ui->perc_caraShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
578 "stop: 0 green, stop: %1 green, stop: %2 red, stop: 1 red);}").arg(s1 - 0.00001).arg(s1));
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
579 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
580 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
581
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 void EditProduct::ferment_lintner_valueChanged(int value)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
584 {
229
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
585 /*
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
586 * Calculate the color stop positions
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
587 */
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
588 if (value < 30) {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
589 ui->lintnerShow->setStyleSheet(bar_red);
229
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
590 } else {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
591 double s1 = 30.0 / value;
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
592 if (value < 40) {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
593 ui->lintnerShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
594 "stop: 0 red, stop: %1 red, stop: %2 orange, stop: 1 orange);}").arg(s1 - 0.00001).arg(s1));
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
595 } else {
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
596 double s2 = 40.0 / value;
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
597 ui->lintnerShow->setStyleSheet(QString("QProgressBar::chunk {background-color: qlineargradient(x0: 0, x2: 1, "
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
598 "stop: 0 red, stop: %1 red, stop: %2 orange, stop: %3 orange, stop: %4 green, stop: 1 green"
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
599 ");}").arg(s1 - 0.00003).arg(s1 - 0.00002).arg(s2 - 0.00001).arg(s2));
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
600 }
815ee118ad49 The abused progress bars in the fermentables tab now show the stacked colors like I want them.
Michiel Broek <mbroek@mbse.eu>
parents: 225
diff changeset
601 }
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
602 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
603
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
604
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
605 void EditProduct::addFermentRow_clicked()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
606 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
607 Fermentables newf;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
608
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
609 qDebug() << "Add fermentable row";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
610
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
611 for (int i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
612 if (product->fermentables.at(i).amount == 0 && product->fermentables.at(i).color == 0)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
613 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
614 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
615
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
616 newf.name = "Select one";
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
617 newf.origin = "";
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
618 newf.supplier = "";
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
619 newf.amount = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
620 newf.cost = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
621 newf.type = FERMENTABLE_TYPE_GRAIN;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
622 newf.yield = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
623 newf.color = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
624 newf.coarse_fine_diff = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
625 newf.moisture = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
626 newf.diastatic_power = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
627 newf.protein = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
628 newf.dissolved_protein = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
629 newf.max_in_batch = 100;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
630 newf.graintype = FERMENTABLE_GRAINTYPE_BASE;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
631 newf.added = FERMENTABLE_ADDED_MASH;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
632 newf.recommend_mash = true;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
633 newf.add_after_boil = false;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
634 newf.adjust_to_total_100 = false;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
635 newf.percentage = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
636 newf.di_ph = 0;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
637 newf.acid_to_ph_57 = 0;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
638
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
639 product->fermentables.append(newf);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
640 emit refreshAll();
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
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
643
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
644 void EditProduct::deleteFermentRow_clicked()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
645 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
646 if (product->locked)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
647 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
648
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
649 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
650 int row = pb->objectName().toInt();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
651 qDebug() << "Delete fermentable row" << row << product->fermentables.size();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
652
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
653 if (product->fermentables.size() < 1)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
654 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
655
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
656 int rc = QMessageBox::warning(this, tr("Delete fermentable"), tr("Delete %1").arg(product->fermentables.at(row).name),
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
657 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
658 if (rc == QMessageBox::No)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
659 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
660
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
661 product->fermentables.removeAt(row);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
662
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
663 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
664 * Recalculate the percentages on the rows left.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
665 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
666 double total = 0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
667 for (int i = 0; i < product->fermentables.size(); i++)
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
668 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) // Only before bottle/kegging
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
669 total += product->fermentables.at(i).amount;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
670 for (int i = 0; i < product->fermentables.size(); i++)
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
671 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE)
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
672 product->fermentables[i].percentage = product->fermentables.at(i).amount / total * 100;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
673
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
674 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
675 emit refreshAll();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
676 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
677
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 void EditProduct::ferment_amount_changed(double val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
680 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
681 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
682 double total = 0, perc;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
683
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
684 if (product->fermentables_use100 && product->fermentables.at(product->fermentables_row).added < FERMENTABLE_ADDED_BOTTLE)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
685 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
686
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
687 qDebug() << "ferment_amount_changed()" << product->fermentables_row << val;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
688
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
689 product->fermentables[product->fermentables_row].amount = val;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
690 item = new QTableWidgetItem(QString("%1 Kg").arg(val, 4, 'f', 3, '0'));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
691 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
692 ui->fermentablesTable->setItem(product->fermentables_row, 7, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
693
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
694 for (int i = 0; i < product->fermentables.size(); i++)
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
695 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) // Only before bottle/kegging
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
696 total += product->fermentables.at(i).amount;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
697 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
698 * Recalculate the percentages
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
699 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
700 for (int i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
701 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) {
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
702 perc = product->fermentables.at(i).amount / total * 100;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
703 product->fermentables[i].percentage = perc;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
704 item = new QTableWidgetItem(QString("%1%").arg(perc, 2, 'f', 1, '0'));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
705 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
706 ui->fermentablesTable->setItem(i, 8, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
707 if (i == product->fermentables_row)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
708 this->pctEdit->setValue(perc);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
709 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
710 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
711 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
712 }
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 void EditProduct::ferment_pct_changed(double val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
716 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
717 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
718 double total = 0, row100 = -1;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
719
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
720 if (! product->fermentables_use100)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
721 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
722
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
723 qDebug() << "ferment_pct_changed()" << product->fermentables_row << val;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
724 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
725 * Since we have arrived here, adjust_to_100 is active and
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
726 * this is not the entry to be adjusted to 100.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
727 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
728 for (int i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
729 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) // Only before bottle/kegging
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
730 total += product->fermentables.at(i).amount;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
731 if (product->fermentables.at(i).adjust_to_total_100)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
732 row100 = i;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
733 }
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
734 double oldperc = product->fermentables.at(product->fermentables_row).percentage;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
735 double diffp = val - oldperc;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
736 double diffw = (diffp / 100) * total;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
737 qDebug() << "row100" << row100 << "total" << total << "diff kg" << diffw << "diff %" << diffp;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
738
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
739 product->fermentables[product->fermentables_row].percentage += diffp;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
740 product->fermentables[product->fermentables_row].amount += diffw;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
741 product->fermentables[row100].percentage -= diffp;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
742 product->fermentables[row100].amount -= diffw;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
743
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
744 item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables[product->fermentables_row].amount, 4, 'f', 3, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
745 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
746 ui->fermentablesTable->setItem(product->fermentables_row, 7, item);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
747 this->famountEdit->setValue(product->fermentables[product->fermentables_row].amount);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
748
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
749 item = new QTableWidgetItem(QString("%1%").arg(product->fermentables[product->fermentables_row].percentage, 2, 'f', 1, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
750 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
751 ui->fermentablesTable->setItem(product->fermentables_row, 8, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
752
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
753 item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables[row100].amount, 4, 'f', 3, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
754 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
755 ui->fermentablesTable->setItem(row100, 7, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
756
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
757 item = new QTableWidgetItem(QString("%1%").arg(product->fermentables[row100].percentage, 2, 'f', 1, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
758 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
759 ui->fermentablesTable->setItem(row100, 8, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
760
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
761 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
762 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
763
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
764
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
765 void EditProduct::ferment_to100_changed(bool val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
766 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
767 qDebug() << "ferment_to100_changed()" << product->fermentables_row << val << product->fermentables_use100;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
768
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
769 if (product->fermentables.at(product->fermentables_row).added >= FERMENTABLE_ADDED_BOTTLE) {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
770 const QSignalBlocker blocker1(to100Edit);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
771 product->fermentables[product->fermentables_row].adjust_to_total_100 = false;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
772 to100Edit->setChecked(false);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
773 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
774 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
775
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 * Three scenario's.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
778 * 1. There is no fermentable selected yet, just mark it.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
779 * 2. There is current one is selected, deselect it.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
780 * 3. There is another one selected, deselect and select this one.
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
781 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
782 if (! product->fermentables_use100 && val) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
783 /* Scenario 1. */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
784 product->fermentables_use100 = true;
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
785 product->fermentables[product->fermentables_row].adjust_to_total_100 = true;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
786 pctEdit->setReadOnly(false);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
787 famountEdit->setReadOnly(true);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
788 } else if (product->fermentables_use100 && product->fermentables[product->fermentables_row].adjust_to_total_100 && ! val) {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
789 /* Scenario 2. */
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
790 product->fermentables[product->fermentables_row].adjust_to_total_100 = false;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
791 product->fermentables_use100 = false;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
792 pctEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
793 famountEdit->setReadOnly(false);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
794 } else if (product->fermentables_use100 && ! product->fermentables[product->fermentables_row].adjust_to_total_100 && val) {
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
795 /* Scenario 3. */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
796 for (int i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
797 product->fermentables[i].adjust_to_total_100 = false;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
798 }
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
799 product->fermentables[product->fermentables_row].adjust_to_total_100 = true;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
800 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
801 qDebug() << "bug";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
802 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
803 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
804
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
805 for (int i = 0; i < product->fermentables.size(); i++) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
806 to100Fermentables(i);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
807 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
808 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
809 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
810
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
811
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
812 void EditProduct::ferment_select_changed(int val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
813 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
814 QSqlQuery query;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
815 bool instock = finstockEdit->isChecked();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
816 QString w;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
817 QTableWidgetItem *item;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
818
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
819 if (val < 1)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
820 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
821
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
822 qDebug() << "ferment_select_changed()" << product->fermentables_row << val << instock;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
823
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
824 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
825 * Search the fermentable 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
826 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
827 QString sql = "SELECT name,origin,supplier,cost,type,yield,color,coarse_fine_diff,moisture,diastatic_power,protein,dissolved_protein,max_in_batch,"
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: 187
diff changeset
828 "graintype,recommend_mash,add_after_boil,di_ph,acid_to_ph_57,inventory FROM inventory_fermentables ";
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
829 if (instock)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
830 sql.append("WHERE inventory > 0 ");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
831 sql.append("ORDER BY supplier,name");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
832 query.prepare(sql);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
833 query.exec();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
834 query.first();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
835 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
836 query.next();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
837 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
838
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
839 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
840 * Replace the fermentable record contents
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
841 */
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
842 product->fermentables[product->fermentables_row].name = query.value(0).toString();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
843 product->fermentables[product->fermentables_row].origin = query.value(1).toString();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
844 product->fermentables[product->fermentables_row].supplier = query.value(2).toString();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
845 product->fermentables[product->fermentables_row].cost = query.value(3).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
846 product->fermentables[product->fermentables_row].type = query.value(4).toInt();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
847 product->fermentables[product->fermentables_row].yield = query.value(5).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
848 product->fermentables[product->fermentables_row].color = query.value(6).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
849 product->fermentables[product->fermentables_row].coarse_fine_diff = query.value(7).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
850 product->fermentables[product->fermentables_row].moisture = query.value(8).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
851 product->fermentables[product->fermentables_row].diastatic_power = query.value(9).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
852 product->fermentables[product->fermentables_row].protein = query.value(10).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
853 product->fermentables[product->fermentables_row].dissolved_protein = query.value(11).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
854 product->fermentables[product->fermentables_row].max_in_batch = query.value(12).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
855 product->fermentables[product->fermentables_row].graintype = query.value(13).toInt();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
856 product->fermentables[product->fermentables_row].recommend_mash = query.value(14).toInt() ? true:false;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
857 product->fermentables[product->fermentables_row].add_after_boil = query.value(15).toInt() ? true:false;
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
858 product->fermentables[product->fermentables_row].di_ph = query.value(16).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
859 product->fermentables[product->fermentables_row].acid_to_ph_57 = query.value(17).toDouble();
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
860 product->fermentables[product->fermentables_row].inventory = query.value(18).toDouble();
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
861
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
862 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
863 * Update the visible fields
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
864 */
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
865 fnameEdit->setText(product->fermentables.at(product->fermentables_row).name);
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
866 fsupplierEdit->setText(product->fermentables.at(product->fermentables_row).supplier);
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
867 fmaxEdit->setValue(product->fermentables.at(product->fermentables_row).max_in_batch);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
868
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
869 ui->fermentablesTable->setItem(product->fermentables_row, 0, new QTableWidgetItem(product->fermentables.at(product->fermentables_row).supplier));
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
870 ui->fermentablesTable->setItem(product->fermentables_row, 1, new QTableWidgetItem(product->fermentables.at(product->fermentables_row).name));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
871
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
872 w = QString("%1").arg(product->fermentables.at(product->fermentables_row).color, 1, 'f', 0, '0');
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
873 item = new QTableWidgetItem(w);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
874 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
875 ui->fermentablesTable->setItem(product->fermentables_row, 2, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
876
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 284
diff changeset
877 item = new QTableWidgetItem(QCoreApplication::translate("FermentableType", g_fermentable_types[product->fermentables.at(product->fermentables_row).type]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
878 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
879 ui->fermentablesTable->setItem(product->fermentables_row, 3, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
880
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 284
diff changeset
881 item = new QTableWidgetItem(QCoreApplication::translate("FermentableGraintype", g_fermentable_graintypes[product->fermentables.at(product->fermentables_row).graintype]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
882 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
883 ui->fermentablesTable->setItem(product->fermentables_row, 4, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
884
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
885 item = new QTableWidgetItem(QString("%1%").arg(product->fermentables.at(product->fermentables_row).yield, 2, 'f', 1, '0'));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
886 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
887 ui->fermentablesTable->setItem(product->fermentables_row, 6, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
888
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
889 item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables.at(product->fermentables_row).inventory, 4, 'f', 3, '0'));
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: 187
diff changeset
890 item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
891 if (product->fermentables.at(product->fermentables_row).inventory < product->fermentables.at(product->fermentables_row).amount)
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: 187
diff changeset
892 item->setForeground(QBrush(QColor(Qt::red)));
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: 187
diff changeset
893 ui->fermentablesTable->setItem(product->fermentables_row, 8, item);
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: 187
diff changeset
894
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
895 calcFermentables();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
896 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
897 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
898
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
899
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
900 void EditProduct::ferment_instock_changed(bool val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
901 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
902 QSqlQuery query;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
903
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
904 qDebug() << "ferment_instock_changed()" << product->fermentables_row << val;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
905
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
906 this->fselectEdit->setCurrentIndex(-1);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
907 this->fselectEdit->clear();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
908 QString sql = "SELECT supplier,name,color,inventory FROM inventory_fermentables ";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
909 if (val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
910 sql.append("WHERE inventory > 0 ");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
911 sql.append("ORDER BY supplier,name");
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
912 query.prepare(sql);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
913 query.exec();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
914 query.first();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
915 this->fselectEdit->addItem(""); // Start with empty value
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
916 for (int i = 0; i < query.size(); i++) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
917 this->fselectEdit->addItem(query.value(0).toString()+" - "+query.value(1).toString()+" ("+query.value(2).toString()+" EBC) "+
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
918 QString("%1 kg").arg(query.value(3).toDouble(), 4, 'f', 3, '0'));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
919 query.next();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
920 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
921 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
922
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
923
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
924 void EditProduct::ferment_added_changed(int val)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
925 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
926 qDebug() << "ferment_added_changed()" << product->fermentables_row << val;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
927
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
928 product->fermentables[product->fermentables_row].added = val;
301
fe6346211b5b Finally the translation of string arrays is working.
Michiel Broek <mbroek@mbse.eu>
parents: 284
diff changeset
929 QTableWidgetItem *item = new QTableWidgetItem(QCoreApplication::translate("FermentableAdded", g_fermentable_added[val]));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
930 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
931 ui->fermentablesTable->setItem(product->fermentables_row, 5, item);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
932
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
933 famountEdit->setReadOnly(product->fermentables_use100 && product->fermentables.at(product->fermentables_row).added < FERMENTABLE_ADDED_BOTTLE);
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
934 pctEdit->setReadOnly(! (product->fermentables_use100 && product->fermentables.at(product->fermentables_row).added < FERMENTABLE_ADDED_BOTTLE));
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
935
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
936 double total = 0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
937 for (int i = 0; i < product->fermentables.size(); i++)
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
938 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) // Only before bottle/kegging
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
939 total += product->fermentables.at(i).amount;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
940 for (int i = 0; i < product->fermentables.size(); i++)
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
941 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE)
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
942 product->fermentables[i].percentage = product->fermentables.at(i).amount / total * 100;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
943
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
944 is_changed();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
945 emit refreshAll();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
946 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
947
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
948
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
949 void EditProduct::editFermentRow_clicked()
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
950 {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
951 QSqlQuery query;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
952
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
953 if (product->locked)
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
954 return;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
955
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
956 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
957 product->fermentables_row = pb->objectName().toInt();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
958 qDebug() << "Edit fermentable row" << product->fermentables_row;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
959 Fermentables backup = product->fermentables.at(product->fermentables_row);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
960
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
961 QDialog* dialog = new QDialog(this);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
962 dialog->resize(738, 287);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
963 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
964 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
965 buttonBox->setGeometry(QRect(30, 240, 671, 32));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
966 buttonBox->setLayoutDirection(Qt::LeftToRight);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
967 buttonBox->setOrientation(Qt::Horizontal);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
968 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
969 buttonBox->setCenterButtons(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
970 QLabel *nameLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
971 nameLabel->setObjectName(QString::fromUtf8("nameLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
972 nameLabel->setText(tr("Current ingredient:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
973 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
974 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
975 QLabel *supplierLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
976 supplierLabel->setObjectName(QString::fromUtf8("supplierLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
977 supplierLabel->setText(tr("Supplier:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
978 supplierLabel->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
979 supplierLabel->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
980 QLabel *amountLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
981 amountLabel->setObjectName(QString::fromUtf8("amountLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
982 amountLabel->setText(tr("Amount in kg:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
983 amountLabel->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
984 amountLabel->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
985 QLabel *pctLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
986 pctLabel->setObjectName(QString::fromUtf8("pctLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
987 pctLabel->setText(tr("Percentage in batch:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
988 pctLabel->setGeometry(QRect(10, 130, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
989 pctLabel->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
990 QLabel *to100Label = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
991 to100Label->setObjectName(QString::fromUtf8("to100Label"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
992 to100Label->setText(tr("Auto fill to 100%:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
993 to100Label->setGeometry(QRect(10, 160, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
994 to100Label->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
995 QLabel *addedLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
996 addedLabel->setObjectName(QString::fromUtf8("addedLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
997 addedLabel->setText(tr("Use at:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
998 addedLabel->setGeometry(QRect(10, 190, 141, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
999 addedLabel->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
1000 QLabel *selectLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1001 selectLabel->setObjectName(QString::fromUtf8("selectLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1002 selectLabel->setText(tr("Select ingredient:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1003 selectLabel->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
1004 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
1005 QLabel *instockLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1006 instockLabel->setObjectName(QString::fromUtf8("instockLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1007 instockLabel->setText(tr("In stock:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1008 instockLabel->setGeometry(QRect(525, 70, 121, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1009 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
1010 QLabel *maxLabel = new QLabel(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1011 maxLabel->setObjectName(QString::fromUtf8("maxLabel"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1012 maxLabel->setText(tr("Max in batch:"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1013 maxLabel->setGeometry(QRect(420, 130, 121, 20));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1014 maxLabel->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
1015
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1016 fselectEdit = new QComboBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1017 fselectEdit->setObjectName(QString::fromUtf8("fselectEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1018 fselectEdit->setGeometry(QRect(160, 70, 371, 23));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1019
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1020 fnameEdit = new QLineEdit(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1021 fnameEdit->setObjectName(QString::fromUtf8("fnameEdit"));
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1022 fnameEdit->setText(product->fermentables.at(product->fermentables_row).name);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1023 fnameEdit->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
1024 fnameEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1025 fsupplierEdit = new QLineEdit(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1026 fsupplierEdit->setObjectName(QString::fromUtf8("fsupplierEdit"));
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1027 fsupplierEdit->setText(product->fermentables.at(product->fermentables_row).supplier);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1028 fsupplierEdit->setGeometry(QRect(160, 40, 511, 23));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1029 fsupplierEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1030 famountEdit = new QDoubleSpinBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1031 famountEdit->setObjectName(QString::fromUtf8("famountEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1032 famountEdit->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
1033 famountEdit->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
1034 famountEdit->setAccelerated(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1035 famountEdit->setDecimals(3);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1036 famountEdit->setReadOnly(product->fermentables_use100 && product->fermentables.at(product->fermentables_row).added < 4);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1037 famountEdit->setMaximum(100000.0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1038 famountEdit->setSingleStep(0.0010);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1039 famountEdit->setValue(product->fermentables.at(product->fermentables_row).amount);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1040
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1041 pctEdit = new QDoubleSpinBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1042 pctEdit->setObjectName(QString::fromUtf8("pctEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1043 pctEdit->setGeometry(QRect(160, 130, 121, 24));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1044 pctEdit->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
1045 pctEdit->setAccelerated(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1046 pctEdit->setDecimals(1);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1047 if (product->fermentables_use100 && product->fermentables.at(product->fermentables_row).added < FERMENTABLE_ADDED_BOTTLE) {
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1048 if (product->fermentables.at(product->fermentables_row).adjust_to_total_100)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1049 pctEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1050 else
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1051 pctEdit->setReadOnly(false);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1052 } else {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1053 pctEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1054 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1055 pctEdit->setMaximum(100.0);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1056 pctEdit->setSingleStep(0.1);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1057 pctEdit->setValue(product->fermentables.at(product->fermentables_row).percentage);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1058
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1059 faddedEdit = new QComboBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1060 faddedEdit->setObjectName(QString::fromUtf8("faddedEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1061 faddedEdit->setGeometry(QRect(160, 190, 161, 23));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1062 faddedEdit->addItem(tr("Mash"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1063 faddedEdit->addItem(tr("Boil"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1064 faddedEdit->addItem(tr("Fermentation"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1065 faddedEdit->addItem(tr("Lagering"));
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1066 faddedEdit->setCurrentIndex(product->fermentables.at(product->fermentables_row).added);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1067
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1068 to100Edit = new QCheckBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1069 to100Edit->setObjectName(QString::fromUtf8("to100Edit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1070 to100Edit->setGeometry(QRect(160, 160, 85, 21));
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1071 to100Edit->setChecked(product->fermentables.at(product->fermentables_row).adjust_to_total_100);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1072
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1073 finstockEdit = new QCheckBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1074 finstockEdit->setObjectName(QString::fromUtf8("instockEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1075 finstockEdit->setGeometry(QRect(655, 70, 85, 21));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1076 finstockEdit->setChecked(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1077
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1078 fmaxEdit = new QDoubleSpinBox(dialog);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1079 fmaxEdit->setObjectName(QString::fromUtf8("fmaxEdit"));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1080 fmaxEdit->setGeometry(QRect(550, 130, 121, 24));
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1081 fmaxEdit->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
1082 fmaxEdit->setReadOnly(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1083 fmaxEdit->setButtonSymbols(QAbstractSpinBox::NoButtons);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1084 fmaxEdit->setDecimals(1);
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1085 fmaxEdit->setValue(product->fermentables.at(product->fermentables_row).max_in_batch);
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1086
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1087 ferment_instock_changed(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1088
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1089 connect(fselectEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::ferment_select_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1090 connect(famountEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::ferment_amount_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1091 connect(pctEdit, QOverload<double>::of(&QDoubleSpinBox::valueChanged), this, &EditProduct::ferment_pct_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1092 connect(faddedEdit, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &EditProduct::ferment_added_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1093 connect(to100Edit, &QCheckBox::stateChanged, this, &EditProduct::ferment_to100_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1094 connect(finstockEdit, &QCheckBox::stateChanged, this, &EditProduct::ferment_instock_changed);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1095 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
1096 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
1097
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1098 dialog->setModal(true);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1099 dialog->exec();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1100 if (dialog->result() == QDialog::Rejected) {
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1101 qDebug() << "reject and rollback";
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1102 product->fermentables[product->fermentables_row] = backup;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1103 /*
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1104 * Recalculate the percentages
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1105 */
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1106 double total = 0;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1107 for (int i = 0; i < product->fermentables.size(); i++)
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1108 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) // Only before bottle/kegging
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1109 total += product->fermentables.at(i).amount;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1110 product->fermentables_use100 = false;
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1111 for (int i = 0; i < product->fermentables.size(); i++) {
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1112 if (product->fermentables.at(i).adjust_to_total_100)
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1113 product->fermentables_use100 = true;
283
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1114 if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) {
242a68fa7186 Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents: 229
diff changeset
1115 product->fermentables[i].percentage = product->fermentables.at(i).amount / total * 100;
175
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1116 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1117 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1118 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1119
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1120 disconnect(fselectEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1121 disconnect(famountEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1122 disconnect(pctEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1123 disconnect(faddedEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1124 disconnect(to100Edit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1125 disconnect(finstockEdit, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1126 disconnect(buttonBox, nullptr, nullptr, nullptr);
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1127
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1128 emit refreshAll();
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1129 }
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1130
f1ed3a2a94e9 Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1131

mercurial