Mon, 13 Jun 2022 16:47:52 +0200
Member names for fermentables normalized.
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 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
50 | void EditProduct::refreshFermentables() |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
51 | { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
52 | QString w; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
53 | QWidget* pWidget; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
54 | QHBoxLayout* pLayout; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
55 | QTableWidgetItem *item; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
56 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
57 | qDebug() << "refreshFermentables" << product->fermentables.size(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
58 | 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
|
59 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
60 | 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
|
61 | 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
|
62 | 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
|
63 | 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
|
64 | 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
|
65 | 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
|
66 | 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
|
67 | 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
|
68 | 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
|
69 | 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
|
70 | 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
|
71 | 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
|
72 | 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
|
73 | 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
|
74 | 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
|
75 | 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
|
76 | ui->fermentablesTable->setHorizontalHeaderLabels(labels); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
77 | ui->fermentablesTable->verticalHeader()->hide(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
78 | 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
|
79 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
80 | 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
|
81 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
82 | 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
|
83 | 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
|
84 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
85 | 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
|
86 | item = new QTableWidgetItem(w); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
87 | 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
|
88 | 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
|
89 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
90 | item = new QTableWidgetItem(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
|
91 | 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
|
92 | 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
|
93 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
94 | item = new QTableWidgetItem(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
|
95 | 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
|
96 | 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
|
97 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
98 | item = new QTableWidgetItem(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
|
99 | 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
|
100 | 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
|
101 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
102 | 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
|
103 | 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
|
104 | 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
|
105 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
106 | 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
|
107 | 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
|
108 | 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
|
109 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
110 | item = new QTableWidgetItem(QString("%1 Kg").arg(product->fermentables.at(i).inventory, 4, 'f', 3, '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
|
111 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
112 | if (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
|
113 | item->setForeground(QBrush(QColor(Qt::red))); |
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
|
114 | 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
|
115 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
116 | if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) { |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
117 | 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
|
118 | } else { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
119 | 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
|
120 | } |
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); |
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
|
122 | 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
|
123 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
124 | to100Fermentables(i); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
125 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
126 | /* Add the Delete row button */ |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
127 | if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) { |
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
|
128 | 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
|
129 | 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
|
130 | 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
|
131 | 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
|
132 | 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
|
133 | 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
|
134 | 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
|
135 | 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
|
136 | 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
|
137 | 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
|
138 | |
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
|
139 | 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
|
140 | 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
|
141 | 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
|
142 | 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
|
143 | 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
|
144 | 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
|
145 | 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
|
146 | 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
|
147 | 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
|
148 | 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
|
149 | } 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
|
150 | item = new QTableWidgetItem(""); |
bb6c06910f0f
Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
187
diff
changeset
|
151 | item->setToolTip(tr("Edit this from the package tab")); |
bb6c06910f0f
Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
187
diff
changeset
|
152 | ui->fermentablesTable->setItem(i, 11, 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
|
153 | item = new QTableWidgetItem(""); |
bb6c06910f0f
Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
187
diff
changeset
|
154 | item->setToolTip(tr("Edit this from the package tab")); |
bb6c06910f0f
Added calcSupplies() which shows if ingredients are in stock to brew the recipe. In tab 3, changed the fermentables numbers into more readable enum constants. Disable delete and edit buttons in fermentables rows for bottle and kegs sugars. Better mash time calculation in calcFermentables. Added check supplies. Added recalculate volumes. Update inventory when a fermentable is replaced. Added tooltips in brewing salts fields in the miscs table.
Michiel Broek <mbroek@mbse.eu>
parents:
187
diff
changeset
|
155 | ui->fermentablesTable->setItem(i, 12, 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
|
156 | } |
175
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
157 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
158 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
159 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
160 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
161 | void EditProduct::calcFermentables() |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
162 | { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
163 | 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
|
164 | 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
|
165 | 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
|
166 | 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
|
167 | 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
|
168 | double mvol = 0; // Mash volume |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
169 | 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
|
170 | 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
|
171 | 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
|
172 | 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
|
173 | 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
|
174 | 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
|
175 | 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
|
176 | 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
|
177 | 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
|
178 | 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
|
179 | 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
|
180 | 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
|
181 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
182 | qDebug() << "calcFermentables()"; |
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 | * 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
|
186 | * 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
|
187 | */ |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
188 | if (product->mashs.size() > 0) { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
189 | 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
|
190 | 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
|
191 | mashinfuse += product->mashs.at(i).step_infuse_amount; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
192 | if (product->mashs.at(i).step_temp < 75) { // Ignore mashout |
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
|
193 | 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
|
194 | 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
|
195 | 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
|
196 | 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
|
197 | 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
|
198 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
199 | } |
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
|
200 | mashtime += 5; // Correction for missing last ramp_time. |
175
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
201 | mashtemp = mashtemp / mashtime; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
202 | mvol = mashinfuse; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
203 | 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
|
204 | } else { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
205 | qDebug() << " no mash schedule"; |
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 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
208 | 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
|
209 | 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
|
210 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
211 | if (product->fermentables.size() < 1) { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
212 | qDebug() << " no fermentables, return."; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
213 | product->est_og = 0.980; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
214 | 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
|
215 | 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
|
216 | 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
|
217 | 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
|
218 | product->est_color = 0; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
219 | ui->est_colorEdit->setValue(0); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
220 | 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
|
221 | ui->est_color2Edit->setValue(0); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
222 | 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
|
223 | ui->est_colorShow->setValue(0); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
224 | ui->perc_mashShow->setValue(0); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
225 | ui->perc_sugarsShow->setValue(0); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
226 | ui->perc_caraShow->setValue(0); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
227 | ui->lintnerShow->setValue(0); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
228 | product->est_fg = 0.980; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
229 | 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
|
230 | 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
|
231 | 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
|
232 | ui->est_abvEdit->setValue(0); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
233 | ui->est_abv2Edit->setValue(0); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
234 | ui->est_abvShow->setValue(0); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
235 | product->est_abv = 0; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
236 | ui->calEdit->setValue(0); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
237 | 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
|
238 | 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
|
239 | return; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
240 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
241 | 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
|
242 | |
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
|
243 | product->fermentables_ok = true; |
175
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
244 | product->mashs_kg = 0; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
245 | for (i = 0; i < product->fermentables.size(); i++) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
246 | 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
|
247 | psugar += product->fermentables.at(i).percentage; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
248 | 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
|
249 | pcara += product->fermentables.at(i).percentage; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
250 | 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
|
251 | 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
|
252 | if (mvol > 0) { // If mash volume is known |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
253 | 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
|
254 | s += d; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
255 | } |
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
|
256 | 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
|
257 | sugarsm += d; |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
258 | 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
|
259 | } |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
260 | 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
|
261 | sugarsf += d; |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
262 | 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
|
263 | 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
|
264 | addedS += product->fermentables.at(i).amount * x; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
265 | addedmass += product->fermentables.at(i).amount; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
266 | 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
|
267 | } |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
268 | if (product->fermentables.at(i).added == FERMENTABLE_ADDED_MASH && |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
269 | (product->fermentables.at(i).type == FERMENTABLE_TYPE_GRAIN || product->fermentables.at(i).type == FERMENTABLE_TYPE_ADJUCT) && |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
270 | product->fermentables.at(i).color < 50) { |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
271 | 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
|
272 | } |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
273 | if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) { |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
274 | 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
|
275 | 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
|
276 | 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
|
277 | } |
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
|
278 | /* Check supplies */ |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
279 | 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
|
280 | ((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
|
281 | ((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
|
282 | ((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
|
283 | ((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
|
284 | 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
|
285 | 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
|
286 | } |
175
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
287 | } |
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
|
288 | 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
|
289 | 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
|
290 | 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
|
291 | qDebug() << " sugarsf" << sugarsf << "sugarsm" << sugarsm; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
292 | |
182
545d31130844
Added brewday mash results box.
Michiel Broek <mbroek@mbse.eu>
parents:
181
diff
changeset
|
293 | double v = s / sugardensity + mvol; |
545d31130844
Added brewday mash results box.
Michiel Broek <mbroek@mbse.eu>
parents:
181
diff
changeset
|
294 | s = 1000 * s / (v * 10); //deg. Plato |
545d31130844
Added brewday mash results box.
Michiel Broek <mbroek@mbse.eu>
parents:
181
diff
changeset
|
295 | product->est_mash_sg = Utils::plato_to_sg(s); |
545d31130844
Added brewday mash results box.
Michiel Broek <mbroek@mbse.eu>
parents:
181
diff
changeset
|
296 | ui->brew_mashsgShow->setValue(product->est_mash_sg); |
545d31130844
Added brewday mash results box.
Michiel Broek <mbroek@mbse.eu>
parents:
181
diff
changeset
|
297 | |
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
|
298 | /* 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
|
299 | 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
|
300 | qDebug() << " OG" << ui->est_ogEdit->value() << 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
|
301 | ui->est_ogEdit->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
|
302 | 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
|
303 | ui->est_og4Edit->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
|
304 | ui->est_ogShow->setValue(product->est_og); |
175
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
305 | |
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
|
306 | /* 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
|
307 | 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
|
308 | 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
|
309 | |
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
|
310 | /* 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
|
311 | 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
|
312 | 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
|
313 | 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
|
314 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
315 | /* |
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
|
316 | * 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
|
317 | */ |
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
|
318 | 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
|
319 | 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
|
320 | 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
|
321 | 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
|
322 | 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
|
323 | 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
|
324 | } |
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
|
325 | 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
|
326 | 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
|
327 | /* 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
|
328 | 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
|
329 | 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
|
330 | 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
|
331 | 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
|
332 | |
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 | 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
|
334 | 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
|
335 | 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
|
336 | |
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
|
337 | 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
|
338 | 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
|
339 | 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
|
340 | 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
|
341 | // 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
|
342 | 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
|
343 | 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
|
344 | } 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
|
345 | 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
|
346 | } 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
|
347 | 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
|
348 | 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
|
349 | } |
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 | 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
|
351 | 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
|
352 | } |
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 | } 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
|
354 | // 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
|
355 | 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
|
356 | 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
|
357 | 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
|
358 | 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
|
359 | } |
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 | |
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 | /* |
175
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
362 | * Color of the wort |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
363 | */ |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
364 | 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
|
365 | 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
|
366 | } 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
|
367 | 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
|
368 | } 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
|
369 | 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
|
370 | 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
|
371 | //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
|
372 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
373 | 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
|
374 | product->est_color = color; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
375 | ui->est_colorEdit->setValue(color); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
376 | 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
|
377 | ui->est_color2Edit->setValue(color); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
378 | 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
|
379 | ui->est_colorShow->setValue(color); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
380 | |
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
|
381 | ui->perc_mashShow->setValue(round(product->mashs_kg / product->eq_mash_max * 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
|
382 | 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
|
383 | 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
|
384 | 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
|
385 | if (product->mashs_kg > 0) { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
386 | 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
|
387 | 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
|
388 | } else { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
389 | qDebug() << " lintner N/A"; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
390 | ui->lintnerShow->setValue(0); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
391 | } |
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 | /* |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
394 | * Calculate the apparant attenuation. |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
395 | */ |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
396 | 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
|
397 | 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
|
398 | product->yeasts_ok = true; |
175
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
399 | if (product->yeasts.size() > 0) { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
400 | for (i = 0; i < product->yeasts.size(); i++) { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
401 | if (product->yeasts.at(i).y_use == 0) { // Used in primary |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
402 | if (product->yeasts.at(i).y_attenuation > svg) |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
403 | svg = product->yeasts.at(i).y_attenuation; // Take the highest if multiple yeasts. |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
404 | } |
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
|
405 | if (product->yeasts.at(i).y_form == 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
|
406 | initcells += (product->yeasts.at(i).y_cells / 1000000000) * product->yeasts.at(i).y_amount * (product->starter_viability / 100); |
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
|
407 | 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
|
408 | initcells += (product->yeasts.at(i).y_cells / 1000000) * product->yeasts.at(i).y_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
|
409 | // TODO: brett or others in secondary. |
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
|
410 | if ((((product->inventory_reduced <= PROD_STAGE_PRIMARY) && (product->yeasts.at(i).y_use == 0)) || // Primary |
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
|
411 | ((product->inventory_reduced <= PROD_STAGE_SECONDARY) && (product->yeasts.at(i).y_use == 1)) || // Secondary |
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
|
412 | ((product->inventory_reduced <= PROD_STAGE_TERTIARY) && (product->yeasts.at(i).y_use == 2)) || // Tertiary |
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
|
413 | ((product->inventory_reduced <= PROD_STAGE_PACKAGE) && (product->yeasts.at(i).y_use == 3))) && // Bottle |
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
|
414 | (product->yeasts.at(i).y_inventory < product->yeasts.at(i).y_amount)) { |
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
|
415 | 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
|
416 | } |
175
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
417 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
418 | qDebug() << " SVG" << svg; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
419 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
420 | if (svg == 0) |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
421 | svg = 77.0; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
422 | ui->est_svgEdit->setValue(svg); |
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 | 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
|
425 | 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
|
426 | 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
|
427 | 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
|
428 | qDebug() << " FG" << ui->est_fgEdit->value() << 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
|
429 | ui->est_fgEdit->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
|
430 | 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
|
431 | ui->est_fgShow->setValue(product->est_fg); |
175
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
432 | |
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
|
433 | /* |
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
|
434 | * Calculate the final values if available. |
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
|
435 | */ |
219
fa7cad488e27
Added fermentation stages data. The two graphs are for later.
Michiel Broek <mbroek@mbse.eu>
parents:
191
diff
changeset
|
436 | if ((product->stage >= PROD_STAGE_PACKAGE) && (product->fg > 0.990) && (product->fg < product->brew_fermenter_sg)) { |
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
|
437 | |
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
|
438 | } |
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 | |
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
|
440 | 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
|
441 | 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
|
442 | 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
|
443 | 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
|
444 | 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
|
445 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
446 | /* |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
447 | * 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
|
448 | * 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
|
449 | */ |
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
|
450 | 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
|
451 | 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
|
452 | 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
|
453 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
454 | // Bottle priming |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
455 | double priming_total = 0; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
456 | for (i = 0; i < product->fermentables.size(); i++) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
457 | if (product->fermentables.at(i).added == FERMENTABLE_ADDED_BOTTLE) { |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
458 | 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
|
459 | product->fermentables.at(i).amount; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
460 | 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
|
461 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
462 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
463 | 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
|
464 | double volco2 = grl * 0.510; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
465 | 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
|
466 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
467 | if (volco2 > 0) { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
468 | product->est_carb = volco2; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
469 | 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
|
470 | 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
|
471 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
472 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
473 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
474 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
475 | void EditProduct::calcFermentablesFromOG(double og) |
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 | qDebug() << "calcFermentablesFromOG" << og; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
478 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
479 | int i; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
480 | double totmass = 0; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
481 | double tot = 0; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
482 | double d, amount; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
483 | double efficiency = product->efficiency; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
484 | 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
|
485 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
486 | for (i = 0; i < product->fermentables.size(); i++) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
487 | if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) { |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
488 | d = product->fermentables.at(i).percentage / 100.0 * |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
489 | (product->fermentables.at(i).yield / 100.0) * |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
490 | (1 - product->fermentables.at(i).moisture / 100.0); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
491 | 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
|
492 | d = efficiency / 100.0 * d; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
493 | tot += d; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
494 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
495 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
496 | if (tot) |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
497 | 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
|
498 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
499 | if (totmass) { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
500 | for (i = 0; i < product->fermentables.size(); i++) { |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
501 | 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
|
502 | 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
|
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 | |
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 | 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
|
509 | { |
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
|
510 | if (value < 90) { |
175
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
511 | 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
|
512 | } 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
|
513 | 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
|
514 | 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
|
515 | 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
|
516 | "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
|
517 | ");}").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
|
518 | } 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
|
519 | 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
|
520 | 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
|
521 | "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
|
522 | ");}").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
|
523 | } |
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
|
524 | } |
175
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 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
528 | 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
|
529 | { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
530 | if (value < 20) |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
531 | 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
|
532 | 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
|
533 | 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
|
534 | 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
|
535 | "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
|
536 | } |
175
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 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
540 | 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
|
541 | { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
542 | if (value < 25) |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
543 | 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
|
544 | 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
|
545 | 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
|
546 | 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
|
547 | "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
|
548 | } |
175
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
549 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
550 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
551 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
552 | 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
|
553 | { |
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
|
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 | * 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
|
556 | */ |
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
|
557 | if (value < 30) { |
175
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
558 | 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
|
559 | } 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
|
560 | 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
|
561 | 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
|
562 | 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
|
563 | "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
|
564 | } 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
|
565 | 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
|
566 | 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
|
567 | "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
|
568 | ");}").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
|
569 | } |
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
|
570 | } |
175
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
571 | } |
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 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
574 | void EditProduct::addFermentRow_clicked() |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
575 | { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
576 | Fermentables newf; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
577 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
578 | qDebug() << "Add fermentable row"; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
579 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
580 | 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
|
581 | 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
|
582 | 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
|
583 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
584 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
585 | newf.name = "Select one"; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
586 | newf.origin = ""; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
587 | newf.supplier = ""; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
588 | newf.amount = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
589 | newf.cost = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
590 | newf.type = FERMENTABLE_TYPE_GRAIN; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
591 | newf.yield = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
592 | newf.color = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
593 | newf.coarse_fine_diff = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
594 | newf.moisture = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
595 | newf.diastatic_power = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
596 | newf.protein = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
597 | newf.dissolved_protein = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
598 | newf.max_in_batch = 100; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
599 | newf.graintype = FERMENTABLE_GRAINTYPE_BASE; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
600 | newf.added = FERMENTABLE_ADDED_MASH; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
601 | newf.recommend_mash = true; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
602 | newf.add_after_boil = false; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
603 | newf.adjust_to_total_100 = false; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
604 | newf.percentage = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
605 | newf.di_ph = 0; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
606 | 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
|
607 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
608 | product->fermentables.append(newf); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
609 | emit refreshAll(); |
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 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
612 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
613 | void EditProduct::deleteFermentRow_clicked() |
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 | if (product->locked) |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
616 | return; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
617 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
618 | 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
|
619 | int row = pb->objectName().toInt(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
620 | 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
|
621 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
622 | if (product->fermentables.size() < 1) |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
623 | return; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
624 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
625 | 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
|
626 | 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
|
627 | if (rc == QMessageBox::No) |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
628 | return; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
629 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
630 | product->fermentables.removeAt(row); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
631 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
632 | /* |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
633 | * 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
|
634 | */ |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
635 | double total = 0; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
636 | 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
|
637 | 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
|
638 | 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
|
639 | 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
|
640 | if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
641 | 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
|
642 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
643 | is_changed(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
644 | emit refreshAll(); |
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 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
647 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
648 | 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
|
649 | { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
650 | QTableWidgetItem *item; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
651 | double total = 0, perc; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
652 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
653 | 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
|
654 | return; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
655 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
656 | 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
|
657 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
658 | 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
|
659 | 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
|
660 | 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
|
661 | 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
|
662 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
663 | 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
|
664 | 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
|
665 | 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
|
666 | /* |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
667 | * Recalculate the percentages |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
668 | */ |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
669 | 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
|
670 | if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) { |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
671 | perc = product->fermentables.at(i).amount / total * 100; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
672 | 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
|
673 | 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
|
674 | 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
|
675 | 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
|
676 | if (i == product->fermentables_row) |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
677 | this->pctEdit->setValue(perc); |
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 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
680 | is_changed(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
681 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
682 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
683 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
684 | 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
|
685 | { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
686 | QTableWidgetItem *item; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
687 | double total = 0, row100 = -1; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
688 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
689 | if (! product->fermentables_use100) |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
690 | return; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
691 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
692 | 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
|
693 | /* |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
694 | * 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
|
695 | * 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
|
696 | */ |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
697 | 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
|
698 | 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
|
699 | total += product->fermentables.at(i).amount; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
700 | 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
|
701 | row100 = i; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
702 | } |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
703 | 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
|
704 | double diffp = val - oldperc; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
705 | double diffw = (diffp / 100) * total; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
706 | 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
|
707 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
708 | product->fermentables[product->fermentables_row].percentage += diffp; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
709 | product->fermentables[product->fermentables_row].amount += diffw; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
710 | product->fermentables[row100].percentage -= diffp; |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
711 | 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
|
712 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
713 | 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
|
714 | 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
|
715 | ui->fermentablesTable->setItem(product->fermentables_row, 7, item); |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
716 | 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
|
717 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
718 | 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
|
719 | 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
|
720 | 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
|
721 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
722 | 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
|
723 | 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
|
724 | 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
|
725 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
726 | 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
|
727 | 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
|
728 | 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
|
729 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
730 | is_changed(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
731 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
732 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
733 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
734 | 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
|
735 | { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
736 | 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
|
737 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
738 | 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
|
739 | const QSignalBlocker blocker1(to100Edit); |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
740 | 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
|
741 | to100Edit->setChecked(false); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
742 | return; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
743 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
744 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
745 | /* |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
746 | * Three scenario's. |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
747 | * 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
|
748 | * 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
|
749 | * 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
|
750 | */ |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
751 | if (! product->fermentables_use100 && val) { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
752 | /* Scenario 1. */ |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
753 | product->fermentables_use100 = true; |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
754 | 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
|
755 | pctEdit->setReadOnly(false); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
756 | famountEdit->setReadOnly(true); |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
757 | } 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
|
758 | /* Scenario 2. */ |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
759 | 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
|
760 | product->fermentables_use100 = false; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
761 | pctEdit->setReadOnly(true); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
762 | famountEdit->setReadOnly(false); |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
763 | } 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
|
764 | /* Scenario 3. */ |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
765 | 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
|
766 | 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
|
767 | } |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
768 | 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
|
769 | } else { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
770 | qDebug() << "bug"; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
771 | return; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
772 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
773 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
774 | 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
|
775 | to100Fermentables(i); |
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 | is_changed(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
778 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
779 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
780 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
781 | 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
|
782 | { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
783 | QSqlQuery query; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
784 | bool instock = finstockEdit->isChecked(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
785 | QString w; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
786 | QTableWidgetItem *item; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
787 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
788 | if (val < 1) |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
789 | return; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
790 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
791 | 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
|
792 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
793 | /* |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
794 | * 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
|
795 | */ |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
796 | 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
|
797 | "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
|
798 | if (instock) |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
799 | sql.append("WHERE inventory > 0 "); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
800 | 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
|
801 | query.prepare(sql); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
802 | query.exec(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
803 | query.first(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
804 | 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
|
805 | query.next(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
806 | } |
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 | /* |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
809 | * Replace the fermentable record contents |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
810 | */ |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
811 | 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
|
812 | 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
|
813 | 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
|
814 | 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
|
815 | 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
|
816 | 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
|
817 | 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
|
818 | 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
|
819 | 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
|
820 | 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
|
821 | 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
|
822 | 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
|
823 | 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
|
824 | 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
|
825 | 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
|
826 | 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
|
827 | 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
|
828 | 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
|
829 | 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
|
830 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
831 | /* |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
832 | * Update the visible fields |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
833 | */ |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
834 | fnameEdit->setText(product->fermentables.at(product->fermentables_row).name); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
835 | fsupplierEdit->setText(product->fermentables.at(product->fermentables_row).supplier); |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
836 | 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
|
837 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
838 | 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
|
839 | 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
|
840 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
841 | 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
|
842 | item = new QTableWidgetItem(w); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
843 | 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
|
844 | 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
|
845 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
846 | item = new QTableWidgetItem(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
|
847 | 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
|
848 | 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
|
849 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
850 | item = new QTableWidgetItem(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
|
851 | 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
|
852 | 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
|
853 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
854 | 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
|
855 | 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
|
856 | 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
|
857 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
858 | 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
|
859 | item->setTextAlignment(Qt::AlignRight|Qt::AlignVCenter); |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
860 | 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
|
861 | 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
|
862 | 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
|
863 | |
175
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
864 | calcFermentables(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
865 | is_changed(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
866 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
867 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
868 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
869 | 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
|
870 | { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
871 | QSqlQuery query; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
872 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
873 | 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
|
874 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
875 | this->fselectEdit->setCurrentIndex(-1); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
876 | this->fselectEdit->clear(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
877 | 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
|
878 | if (val) |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
879 | sql.append("WHERE inventory > 0 "); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
880 | 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
|
881 | query.prepare(sql); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
882 | query.exec(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
883 | query.first(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
884 | 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
|
885 | 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
|
886 | 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
|
887 | 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
|
888 | query.next(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
889 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
890 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
891 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
892 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
893 | 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
|
894 | { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
895 | 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
|
896 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
897 | product->fermentables[product->fermentables_row].added = val; |
175
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
898 | QTableWidgetItem *item = new QTableWidgetItem(fermentable_added[val]); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
899 | 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
|
900 | 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
|
901 | |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
902 | 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
|
903 | 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
|
904 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
905 | double total = 0; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
906 | 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
|
907 | 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
|
908 | 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
|
909 | 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
|
910 | if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
911 | 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
|
912 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
913 | is_changed(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
914 | emit refreshAll(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
915 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
916 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
917 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
918 | void EditProduct::editFermentRow_clicked() |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
919 | { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
920 | QSqlQuery query; |
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 | if (product->locked) |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
923 | return; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
924 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
925 | 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
|
926 | 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
|
927 | 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
|
928 | 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
|
929 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
930 | QDialog* dialog = new QDialog(this); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
931 | dialog->resize(738, 287); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
932 | QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
933 | buttonBox->setObjectName(QString::fromUtf8("buttonBox")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
934 | 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
|
935 | buttonBox->setLayoutDirection(Qt::LeftToRight); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
936 | buttonBox->setOrientation(Qt::Horizontal); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
937 | 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
|
938 | buttonBox->setCenterButtons(true); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
939 | QLabel *nameLabel = new QLabel(dialog); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
940 | nameLabel->setObjectName(QString::fromUtf8("nameLabel")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
941 | nameLabel->setText(tr("Current ingredient:")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
942 | 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
|
943 | 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
|
944 | QLabel *supplierLabel = new QLabel(dialog); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
945 | supplierLabel->setObjectName(QString::fromUtf8("supplierLabel")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
946 | supplierLabel->setText(tr("Supplier:")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
947 | 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
|
948 | 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
|
949 | QLabel *amountLabel = new QLabel(dialog); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
950 | amountLabel->setObjectName(QString::fromUtf8("amountLabel")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
951 | 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
|
952 | 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
|
953 | 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
|
954 | QLabel *pctLabel = new QLabel(dialog); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
955 | pctLabel->setObjectName(QString::fromUtf8("pctLabel")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
956 | 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
|
957 | 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
|
958 | 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
|
959 | QLabel *to100Label = new QLabel(dialog); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
960 | to100Label->setObjectName(QString::fromUtf8("to100Label")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
961 | 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
|
962 | 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
|
963 | 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
|
964 | QLabel *addedLabel = new QLabel(dialog); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
965 | addedLabel->setObjectName(QString::fromUtf8("addedLabel")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
966 | addedLabel->setText(tr("Use at:")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
967 | 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
|
968 | 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
|
969 | QLabel *selectLabel = new QLabel(dialog); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
970 | selectLabel->setObjectName(QString::fromUtf8("selectLabel")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
971 | selectLabel->setText(tr("Select ingredient:")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
972 | 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
|
973 | 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
|
974 | QLabel *instockLabel = new QLabel(dialog); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
975 | instockLabel->setObjectName(QString::fromUtf8("instockLabel")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
976 | instockLabel->setText(tr("In stock:")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
977 | 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
|
978 | 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
|
979 | QLabel *maxLabel = new QLabel(dialog); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
980 | maxLabel->setObjectName(QString::fromUtf8("maxLabel")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
981 | 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
|
982 | 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
|
983 | 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
|
984 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
985 | fselectEdit = new QComboBox(dialog); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
986 | fselectEdit->setObjectName(QString::fromUtf8("fselectEdit")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
987 | 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
|
988 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
989 | fnameEdit = new QLineEdit(dialog); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
990 | fnameEdit->setObjectName(QString::fromUtf8("fnameEdit")); |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
991 | 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
|
992 | 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
|
993 | fnameEdit->setReadOnly(true); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
994 | fsupplierEdit = new QLineEdit(dialog); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
995 | fsupplierEdit->setObjectName(QString::fromUtf8("fsupplierEdit")); |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
996 | 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
|
997 | 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
|
998 | fsupplierEdit->setReadOnly(true); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
999 | famountEdit = new QDoubleSpinBox(dialog); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1000 | famountEdit->setObjectName(QString::fromUtf8("famountEdit")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1001 | 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
|
1002 | 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
|
1003 | famountEdit->setAccelerated(true); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1004 | famountEdit->setDecimals(3); |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
1005 | 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
|
1006 | famountEdit->setMaximum(100000.0); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1007 | famountEdit->setSingleStep(0.0010); |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
1008 | 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
|
1009 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1010 | pctEdit = new QDoubleSpinBox(dialog); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1011 | pctEdit->setObjectName(QString::fromUtf8("pctEdit")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1012 | 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
|
1013 | 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
|
1014 | pctEdit->setAccelerated(true); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1015 | pctEdit->setDecimals(1); |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
1016 | 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
|
1017 | 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
|
1018 | pctEdit->setReadOnly(true); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1019 | else |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1020 | pctEdit->setReadOnly(false); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1021 | } else { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1022 | pctEdit->setReadOnly(true); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1023 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1024 | pctEdit->setMaximum(100.0); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1025 | pctEdit->setSingleStep(0.1); |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
1026 | 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
|
1027 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1028 | faddedEdit = new QComboBox(dialog); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1029 | faddedEdit->setObjectName(QString::fromUtf8("faddedEdit")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1030 | 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
|
1031 | faddedEdit->addItem(tr("Mash")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1032 | faddedEdit->addItem(tr("Boil")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1033 | faddedEdit->addItem(tr("Fermentation")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1034 | faddedEdit->addItem(tr("Lagering")); |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
1035 | 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
|
1036 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1037 | to100Edit = new QCheckBox(dialog); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1038 | to100Edit->setObjectName(QString::fromUtf8("to100Edit")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1039 | to100Edit->setGeometry(QRect(160, 160, 85, 21)); |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
1040 | 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
|
1041 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1042 | finstockEdit = new QCheckBox(dialog); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1043 | finstockEdit->setObjectName(QString::fromUtf8("instockEdit")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1044 | 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
|
1045 | finstockEdit->setChecked(true); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1046 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1047 | fmaxEdit = new QDoubleSpinBox(dialog); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1048 | fmaxEdit->setObjectName(QString::fromUtf8("fmaxEdit")); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1049 | 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
|
1050 | 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
|
1051 | fmaxEdit->setReadOnly(true); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1052 | fmaxEdit->setButtonSymbols(QAbstractSpinBox::NoButtons); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1053 | fmaxEdit->setDecimals(1); |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
1054 | 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
|
1055 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1056 | ferment_instock_changed(true); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1057 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1058 | 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
|
1059 | 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
|
1060 | 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
|
1061 | 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
|
1062 | 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
|
1063 | 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
|
1064 | 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
|
1065 | 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
|
1066 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1067 | dialog->setModal(true); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1068 | dialog->exec(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1069 | if (dialog->result() == QDialog::Rejected) { |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1070 | qDebug() << "reject and rollback"; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1071 | 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
|
1072 | /* |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1073 | * Recalculate the percentages |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1074 | */ |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1075 | double total = 0; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1076 | 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
|
1077 | 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
|
1078 | 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
|
1079 | product->fermentables_use100 = false; |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1080 | 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
|
1081 | 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
|
1082 | product->fermentables_use100 = true; |
283
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
1083 | if (product->fermentables.at(i).added < FERMENTABLE_ADDED_BOTTLE) { |
242a68fa7186
Member names for fermentables normalized.
Michiel Broek <mbroek@mbse.eu>
parents:
229
diff
changeset
|
1084 | 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
|
1085 | } |
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 | } |
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 | disconnect(fselectEdit, nullptr, nullptr, nullptr); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1090 | disconnect(famountEdit, nullptr, nullptr, nullptr); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1091 | disconnect(pctEdit, nullptr, nullptr, nullptr); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1092 | disconnect(faddedEdit, nullptr, nullptr, nullptr); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1093 | disconnect(to100Edit, nullptr, nullptr, nullptr); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1094 | disconnect(finstockEdit, nullptr, nullptr, nullptr); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1095 | disconnect(buttonBox, nullptr, nullptr, nullptr); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1096 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1097 | emit refreshAll(); |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1098 | } |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1099 | |
f1ed3a2a94e9
Initial import of EditProduct, the part from EditRecipe is ported.
Michiel Broek <mbroek@mbse.eu>
parents:
diff
changeset
|
1100 |